Redux vs Redux Toolkit - Used in react and react-native
Asad Saeed
?? Software Engineer || MERN stack | React.js | Node.js | Express.js | MongoDB | MySQL | Website Development | Frontend Development
Table of contents
Introduction
In reality, #redux in its most basic form is quite simple and easy to grasp. One of the most common and enduring criticisms of #redux is the amount of #code it adds to the #app, which many believe is #unnecessary. To overcome this, the #reduxjs team has put in a tremendous amount of effort and, without a doubt, has produced an outstanding result with Redux Toolkit.
However, the #redux Team recently released #redux #toolkit , an #officially recommended and #SOPE #library (Simple, Opinionated, Powerful, and Effective state management library). It enables us to write more #efficient code, #accelerate #development, and automatically apply best #practices. It was #primarily #designed to address #Redux's #THREE #MAJOR #ISSUES:
Redux Toolkit includes the following features:
Install:
# NPM
npm install @reduxjs/toolkit
# Yarn
yarn add @reduxjs/toolkit
领英推荐
What Extra Features Are Provided:
#RTK employs the ducks #pattern, combining #reducers, #actions, and #constants into a single #file known as a #slice. Each #slice will provide an #initial #state and a #reducer #function for an #object in #store.
As you can see, there are certain disadvantages.
When #redux initially arrived on the #frontend #horizon, many people anticipated it to solve all of our #statemanagement issues. Its connection to #React was so strong that some people began to feel that React was incomplete without #Redux, while Redux author Dan Abramov publicly denied this notion.
#Developers gradually became aware of Redux's limits, which sparked a #debate about whether there are better ways to manage #global state — and, indeed, whether Redux is a viable solution in the first place.
Many of the arguments against Redux stemmed from a variety of perspectives and "best practices" that were eventually deemed mandatory. (In reality, Redux is quite basic and easy to comprehend in its simplest form.) However, one of the most common and ongoing criticisms is the amount of code Redux adds to the app, which many believe is unnecessary.
Those #discussions resulted in the creation of Redux Toolkit (RTK), which is described as "the official, opinionated, batteries-included toolkit for efficient Redux development." The Redux team put in a lot of work on this, and the outcome is undeniably impressive.
Many of the issues about #boilerplate and #redundant #code are resolved with #RTK. As stated in its official documentation, it aids in the resolution of #three #primary #issues with #redux :
In this section, we'll look at how we can use RTK's API to make our Redux applications smaller yet staying strong. As a starting point for our transformation, we'll use the container-presentation pattern and Redux setup from react-boilerplate. I've been using react-boilerplate for a long time, and it's helped me swiftly bootstrap large-scale projects. It has the following container architecture:
One thing to keep in mind: Redux-Thunk is offered as a default option for #async #tasks in RTK and is strongly recommended for simple #data #fetching #operations.
RTK follows the ducks pattern, combining #reducers, #actions, and #constants into a #single #file known as a #slice. Each slice will provide an #initial #state and a #reducer #function for an #object in #store.
If you like this article post, please hit 'like' and share. Show some love by engaging the posts.
Well done, Your web project using Redux is truly impressive. It's evident that you have a deep understanding of Redux and its benefits in managing state in web applications. The code structure is clean and organized, making it easy to follow and maintain. The user interface is sleek and intuitive, providing a smooth experience for users. I appreciate how you've leveraged Redux to handle complex data flows and ensure consistency across components. Your project is a great example of how Redux can enhance the scalability and maintainability of web applications. Keep up the excellent work, and I wish you continued success in your web development journey. For more information visit https://www.dhirubhai.net/feed/update/urn:li:activity:7070291891283480576
?? 2x Certified Adobe Commerce Expert | Magento 2 | Hyv? | Laravel | MERN Stack | Nextjs | React Native | PHP | Typescript
2 年Yar voice b record ker k bajh dy. Itna lmba nhi perha jata