【发布时间】:2020-09-02 03:54:18
【问题描述】:
例如,我有这个 slice,我想在 setUser 中使用 dispatch。我该怎么做?
const contactsSlice = createSlice({
name: 'contacts',
initialState: initialState,
reducers: {
setUsers: (state, { payload }) => {
// I want to use dispatch here
dispatch()
},
toggleFavorite: (state, { payload }) => {
//
},
toggleCheck: (state, { payload }) => {
//
}
}
})
【问题讨论】:
标签: reactjs redux react-redux redux-toolkit