We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
got 10000000 at init and at persist but at rehydrate got 0
import { createSlice } from "@reduxjs/toolkit"; const initialState = { name: "", address: "", balance: 10000000, isLogin: localStorage.getItem("token") ? true : false, }; export const userSlice = createSlice({ name: "user", initialState, reducers: { setUser: (state, action) => { return { ...state, ...action.payload, }; }, updateBalance: (state, action) => { return { ...state, balance: action.payload, }; }, updateAddress: (state, action) => { return { ...state, address: action.payload, }; }, updateName: (state, action) => { return { ...state, name: action.payload, }; }, logIn: (state, action) => { localStorage.setItem("token", action.payload); return { ...state, isLogin: true, }; }, logOut: (state) => { state.name = ""; state.address = ""; state.balance = 0; state.isLogin = false; localStorage.removeItem("token"); }, }, }); export const { setUser, updateName, updateBalance, updateAddress, logIn, logOut } = userSlice.actions; export const getUser = (state) => state.user; export default userSlice.reducer;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
got 10000000 at init and at persist but at rehydrate got 0
The text was updated successfully, but these errors were encountered: