createSliceadvancedconst { createSlice, configureStore, createSelector } = ReduxToolkit
const counterSlice = createSlice({
name: 'counter',
initialState: { value: 0, history: [] },
reducers: {
increment: state => { state.history.push(state.value); state.value += 1 },
},
})Combining createSlice, configureStore, and createSelector gives you a complete, production-ready Redux feature module.
Put it all together: slice, store, selectors, and actions. A real counter that tracks a history of previous values.
Challenge: Implement a counter slice with increment, decrement, and reset reducers. Each mutating action should push the current value to history first. Create memoized selectors selectValue and selectHistoryLength.