Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The configuration for Redux Toolkit is minimal as it provides a set of default values and conventions for setting up a Redux store. The basic configuration for creating a Redux store using Redux Toolkit involves importing the necessary modules and creating a store using the toolkit's createSlice and configureStore functions. Here is an example of a basic configuration:

import { createSlice, configureStore } from '@reduxjs/toolkit';

const counterSlice = createSlice({
  name: 'counter',
  initialState: 0,
  reducers: {
    increment: state => state + 1,
    decrement: state => state - 1,
  },
});

const store = configureStore({
  reducer: counterSlice.reducer,
});

export default store;

In this example, we first create a slice using the createSlice function and define its name, initial state, and reducers. We then create a store using the configureStore function and pass in our reducer, which is generated from our slice using the counterSlice.reducer property. Finally, we export the store so that it can be imported and used in other parts of the application.