UNPKG

create-nova-expo-template

Version:

A template for creating a new React Native app using Expo and TypeScript, with a focus on performance and best practices.

35 lines (30 loc) 791 B
import { createSlice, PayloadAction } from "@reduxjs/toolkit"; import { User } from "@/apis/@types/auth"; interface IAuthState { token?: string | null; userData?: User | null; } const initialState: IAuthState = { token: null, userData: null, }; export const authSlice = createSlice({ name: "auth", initialState, reducers: { login: (state, action: PayloadAction<string>) => ({ ...state, token: action.payload, }), setUserInfo: (state, action: PayloadAction<User>) => ({ ...state, userData: action.payload, }), logout: () => ({ ...initialState, }), }, }); // Action creators are generated for each case reducer function export const { login, setUserInfo, logout } = authSlice.actions; export default authSlice.reducer;