例如,我有这个切片,我想在 setUser 中使用调度。我怎样才能做到这一点?
const contactsSlice = createSlice({
name: 'contacts',
initialState: initialState,
reducers: {
setUsers: (state, { payload }) => {
// I want to use dispatch here
dispatch()
},
toggleFavorite: (state, { payload }) => {
//
},
toggleCheck: (state, { payload }) => {
//
}
}
})