Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Redux 구성 #7

Open
9utty opened this issue Mar 11, 2023 · 0 comments
Open

Global Redux 구성 #7

9utty opened this issue Mar 11, 2023 · 0 comments

Comments

@9utty
Copy link
Member

9utty commented Mar 11, 2023

import { InitialState } from "@react-navigation/native";
import { createSlice, PayloadAction } from "@reduxjs/toolkit";

interface Auth {
  userId: number;
  AccessToken: string;
}

const initialState = {
  isLogin: false,
  userId: 0,
  AccessToken: "",
};

export const GlobalSlice = createSlice({
  name: "global",
  initialState: initialState,
  reducers: {
    addAToken(state, action: PayloadAction<string>) {
      state.AccessToken = action.payload;
      state.isLogin = true;
    },
    addUserId(state, action: PayloadAction<number>) {
      state.userId = action.payload;
    },
  },
});

질문이 있으면 언제든지 남겨주세요!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant