DEV Community

Munni
Munni

Posted on

Redux Toolkit

Redux

Redux is an open-source JavaScript library for managing and centrailizing application state. It most commonly used with libraries such as react or anguler for building user interfaces.A popular state management library. Redux helps you write application that behave consisitently, run in different environment and are easy to test.

Redux Toolkit

The Redux Toolkit package was developed to be the new standard way to write Redux code, handling some major concerns about Redux itself. One important thing to take away is that Redux Toolkit provides us with powerful data fetching and caching capability.

Using redux toolkit was originally created to help address three mejor concerns about Redux:

  • Configuring a Redux store is too complicated.
  • I have to add a lot of packages to get Redux to do anything useful.
  • Redux requires too much boilerplate code.

What’s include Redux Toolkit

configureStore()

  • It can automatically combine your slice reducers , adds whatever redux middleware you supply includes redux-thunk by default and enables use of the redux extention.

createReducer()

  • Reducer support directly mapping specific action types to case reducer function that will update the state when that actionnis dispatched.

createAction()

  • Redux Toolkit provides a function called createAction. Which simply generates action creator that uses the giveb action type , and turns its argument into the payload.

createSlice()

  • createSlice is a higher order function that accepts an initial state, an object full reducer function and slice name. it automatically generates action creators and action types that corresponding the reducers and state.

createSelector()

  • selectors typically expect the Redux state object as an argument , while slice reducers only have access to specific subset of the entire Redux state.

Installation

Redux Toolkit Npm An Existing app.

npm install @reduxjs/toolkit

Top comments (0)