NOTE: This post is not intended to persuade anyone to use one over the other, this post is purely just my personal opinion.
Hey guys! In today's post, I'm going to be talking (...writing) about why I chose to use Recoil over Redux for my React app's state management.
So, just a quick background of how I started my career as a frontend engineer. I finished university in 2017 and started working right away as an Android app developer for about 9 or 10 months. Then I got a new job as .NET developer, that's when I kinda got my hands on frontend development with TypeScript, and there I worked for about 4 months and quit... and the reason was that, uhh, let's just say I care a lot about my mental health ๐
And after that, I got a job as React Native developer and I loved it! And then after working with React Native for almost a year, I got a job as a Frontend engineer and have been working with React until today.
Now, let's get back to the main topic (sorry for the long background).
Since I started working with React Native, I struggled a lot trying to learn and understand how Redux worked, and always got overwhelmed by the boilerplate code of Redux, I know that there are people that prefer a more verbose code, but at least for me, I've had enough working with verbose code and now prefer to have a bit more of abstraction.
So, what exactly is Recoil?
Recoil is a state management library for React, which works and thinks just like React. It is so easy to set up and the syntax is just like using React hooks! Now, I know that Redux also has its hooks approach, but I like the simple setup and the absence of big boilerplate code.
The main difference between Redux and Recoil is the way both libraries store states.
In Redux, we have the concept of a centralized store where all the states would live, but in Recoil, the state is split into individual atoms.
This is the main difference that made me go down the Recoil route for the current project I'm working on for 2 years now and let me tell you guys, I haven't had any performance issues and it's been so easy to manage global state values of my app. And just so you know, the app I'm working on is a pretty data-intensive web app.
So in conclusion, it's been 2 years now since I started using Recoil on my current project and I haven't had any problems with it, I'm still very happy to have replaced Redux with Recoil! And again... I'm not trying to persuade anyone to use Recoil instead of Redux, this is just my opinion and my experience.
This is it for today's post! Thank you all for reading, and happy coding! โ๏ธ