What is the best approach to manage multiple AsyncThunk at single slice. Would be correct if I put computed properties of each async action?
export const register = createAsyncThunk('user/register', async (payload, { rejectWithValue }) => {
})
export const login = createAsyncThunk('user/login', async (payload, { rejectWithValue }) => {
})
export const userSlice = createSlice({
name: "user",
initialState: { currentUser: "", },
extraReducers: {
[register.pending]: (state) => {
},
[register.fulfilled]: (state) => {
},
[register.rejected]: (state) => {
},
[login.pending]: (state) => {
},
[login.fulfilled]: (state) => {
},
[login.rejected]: (state) => {
},
}
});
不确定这是否是您正在寻找的答案,但根据文档显示它是正确的: https ://redux-toolkit.js.org/api/createreducer#usage-with-the-map-object-notation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.