import { createSlice } from '@reduxjs/toolkit'; // Step 3: Define the initial state const initialState = { value: 0 // This is where we start with a value of 0 for the counter }; // Step 4: Create the slice const counterSlice = createSlice({ name: 'counter', // Name of the slice initialState, // The initial state we defined above reducers: { // Here, we define actions to change the value increment: state => { state.value += 1; // Increase the value by 1 }, decrement: state => { state.value -= 1; // Decrease the value by 1 }, reset: state => { state.value = 0; // Reset the value to 0 } } }); // Step 5: Export actions and the reducer export const { increment, decrement, reset } = counterSlice.actions; export default counterSlice.reducer;