2026 East Asia Influencer Marketing Playbook
Mar 10, 2026
Blog
Influencer Marketing
Hi! I’m Chun Wei, front-end developer for the AnyTag team. In this article, I would like to introduce you about Recoil, a state management library for React.
State management is simply a way to engender communication and sharing of data across application. It creates a concreate data structure to represent your application state that you can read and write. In the simplest definition, state are the memory of the application. Since React 16.8, every React component, whether class or functional can have a state.
There are so many state management library that can be used with React project, it can be quite challenge to decide which state management libaray to use for your project. Obviously Redux is one of the most popular React state management library as of the time. However it required a lot of boilerplate even in small application that don’t require a lot of global state management. On the other hand, React Context hook bring more simple configuration compare to Redux, but any change to the value prop causes the consumes Context component and it children to re-render.
In this case, Recoil play a good roles which simple configuration, it does not need to prop drill or set up context providers. Only the component that use the atom will be updated and optimizing renders to make your application fast.
Developers used to manage data with built in state management capabilities of React, but there are certain limitations of built in solutions such as:
Recoil solves the limitation with its Atoms and Selectors. This approach come with:
Recoil is a state management library for React. Before get started, you need to install React. To install recoil, we can use the follow command:
If you using npm:

Or if you’re using yarn:

Components that use Recoil state need to wrap inside RecoilRoot. To appear somewhere in the parent tree, place it in root component as shown below:

Atoms represent a pieces of state. It can be updated and subcribed from any component. Updated of atom will allow all the subscribed components to re-render with a new value. You can create atoms by using the atom functions as shown below:

Components that need to read and write to an atom, need to use useRecoilState() hook as shown below:

Selector represent a piece of derived state which can be defined as the output of passing state to a pure function that modifies the given state in some way. You can declare a selector as shown below:

To read the value of charCountState, we need to use useRecoilValue hook as shown below:

There is nothing wrong to choose with any type of state management library. Like everything else, Recoil is not ideal and has it own drawback. But what I like about Recoil is it easy to understand and simple configuration. It is true that Recoil is one of the great library that help you creating React application with more simpler and even more fun.