ReasonJun

Redux : toolkit API : configureStore() 본문

Frontend/Redux

Redux : toolkit API : configureStore()

ReasonJun 2023. 8. 19. 23:22
728x90

The configureStore() function in Redux Toolkit is a simplified version of the createStore() function in the original Redux library. It takes care of setting up the store with the middleware you need, and it also includes redux-thunk by default.

 

Here is the syntax for using configureStore():

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

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

The reducer parameter is the root reducer of your application. This is the reducer that combines all of your other reducers into a single reducer.

 

The configureStore() function also takes a number of other options, such as the middleware you want to use, the enhancers you want to use, and the configuration for the Redux DevTools Extension.

 

Here is a comparison of the configureStore() function in Redux Toolkit and the createStore() function in the original Redux library:

Feature Redux Toolkit Original Redux
Ease of use Easier to use More complex
Features Includes redux-thunk by default, and also supports other middleware and enhancers Does not include middleware or enhancers by default
Flexibility Less flexible More flexible

Here are some additional benefits of using configureStore():

  • It makes it easy to set up the Redux DevTools Extension.
  • It allows you to use middleware and enhancers without having to write any code.
  • It provides a good starting point for your Redux store.

If you are using Redux, I highly recommend using configureStore(). It is a great way to simplify your Redux code and make your application more maintainable.

728x90

'Frontend > Redux' 카테고리의 다른 글

Redux : createAsyncThunk  (0) 2023.08.20
Redux : toolkit : createAction / createReducer  (0) 2023.08.19
Redux: toolkit  (0) 2023.08.19
Redux : middleware / Thunk  (0) 2023.08.19
Redux : Provider / useSelector / useDispatch  (0) 2023.08.19
Comments