createSlice
CreateSlice is a function in Redux Toolkit that creates a slice of the Redux state by bundling reducers and action creators in a single configuration object. It automates the generation of action types and action creators, reducing boilerplate compared with traditional Redux setups.
Usage: You call createSlice with an object that includes name, initialState, and reducers, with optional extraReducers.
extraReducers allows handling actions defined outside the slice. It can be provided as an object map of
Return value: the call yields an object containing a reducer function to be added to the store
Benefits: reduces boilerplate, ensures consistent action type naming, and works well with TypeScript and createAsyncThunk scenarios.