Our great sponsors
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
It is fully written in Typescript and is highly recommended that Redux Toolkit is used instead of the original Redux when using it for managing global state. It offers a flexible API, making it possible for making the state management scalable without having to worry about the limits of the library. One of the key concepts of Redux is immutability, and Redux Toolkit makes it easier than ever to keep the immutability by already setting up the ImmerJS library internally, so the developer does not have to worry about accidentally modifying the state directly. One of the most noticeable things for developers when switching to Redux Toolkit is the way reducers are created. Previously we used action creators and created a reducer where we handled all the actions. Now we can use the createSlice API to create reducers and it will eliminate the need to write action creators by creating them for you. An example of createSlice can be seen below:
When an action is dispatched, all of the reducers will be notified and every single one of them will check if they can handle the action. Not only that, but the Redux dev tools will be a mess trying to see what action was fired when. That’s why we should try to think of actions as events that happened and not what the action is changing. For example, we should rather have an action called userLoggedIn than setUserId.
Redux Toolkit is a wrapper library written for the original Redux for the sake of making it easier, and faster to use Redux by reducing the boilerplate and introducing features such as thunks out of the box without having to install third-party libraries.
Redux is a library used for global state management, meaning if you have a piece of state that you want to access in different places of your app, you can use Redux to manage that state and make it easily accessible anywhere. The global state can be anything from logged-in user information to UI state such as theme, etc.
Redux is being used a lot together with React apps, however, it is possible to use Redux with any other library. Make sure you check out this tutorial on how to use Redux with React.