JOTAI(GLOBAL STATE MANGEMENT)
Hussain Ahmed Siddiqui
Posted on May 27, 2024
Hey? REACT developers, are you tired of managing the global states on the client side and bored with using the useContext hook to pass the state?
Here is an optimal alternative of this to manage the global state on the client side.
Introduction:
Jotai takes an atomic approach to global React state management.
Build state by combining atoms and renders are automatically optimized based on atom dependency. This solves the extra re-render issue of React context, eliminates the need for memoization, and provides a similar developer experience to signals while maintaining a declarative programming model.
Example
First, create a primitive atom
An atom represents a piece of state. All you need is to specify an initial value, which can be primitive values like strings and numbers, objects, and arrays. You can create as many primitive atoms as you want.
Use the atom in your components
It can be used like React.useState:
for more details: https://jotai.org/
Posted on May 27, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.