import { createSlice } from "@reduxjs/toolkit"; import { actionName } from "actionName-file-path" export const sliceName = createSlice({ name: "any-name", initialState: { // all initial states }, reducers: { // all reducers defined here reducerName(state, action){ // reducer logic } }, extraReducers: { // all async extra reducers defined here [actionName.pending]: (state, action) => { // action object come from actionName // const { response, data, params} = action.payload }, [actionName.fulfilled]: (state, action) => {}, [actionName.rejected]: (state, action) => {}, } }) export const { reducerName } = sliceName.actions; // import them in any components needed export default sliceName.reducer; // import it in rootRedcer (allReducers)