Steps to Install and Import Redux Toolkit(RTK)
Step 1: Redux Toolkit (RTK) Installation
To install the redux toolkit in our project type the following command in the terminal.
// RTK Installation
// using NPM
npm i @reduxjs/toolkit
npm i react-redux // We also need basic redux with this application
// using Yarn
yarn add @reduxjs/toolkit
Step 2: Importing Redux Toolkit (RTK)
We import only the necessary functions in our code
// Importing
import { configureStore } from '@reduxjs/toolkit'; // Creates a store
import { createSlice } from '@reduxjs/toolkit'; // Combines and creates reducer
Dependencies after installing Redux Toolkit:
"dependencies": { "react": "^17.0.2", "react-dom": "^17.0.2", "@reduxjs/toolkit": "^1.6.1", "react-redux": "^7.2.5" }
Redux Toolkit
Redux Toolkit or RTK is an node package that simplify the development by providing utility functions. It is made to simplify the creation of redux store and provide easy state management. It can be easily installed using simple npm commands.
Before the introduction of the Redux toolkit state management was complex in simple redux.
Contact Us