我已经按照文档中的建议使用react-toolkit设置了redux-persist。现在我需要进行一些补液操作,我该怎么做?这是我尝试过但不起作用的。
...
import { REHYDRATE } from 'redux-persist'
...
const accessControl = createSlice({
name: 'accessControl',
initialState,
reducers: {
loginStart(state: AccessControlState) {
state.isLoading = true
},
loginSucces(state: AccessControlState, action: PayloadAction<LoginResponsePayload>) {
state.isAuthenticated = true
state.token = action.payload.access_token
state.isLoading = false
state.error = null
},
loginFailed(state: AccessControlState, action: PayloadAction<string>) {
state.isAuthenticated = false
state.token = ''
state.isLoading = false
state.error = action.payload
},
logout(state: AccessControlState) {
state.isAuthenticated = false
state.token = ''
state.isLoading = false
state.error = null
},
[REHYDRATE]: (state: AccessControlState) …Run Code Online (Sandbox Code Playgroud)