DEV Community

Cover image for JOTAI(GLOBAL STATE MANGEMENT)
Hussain Ahmed Siddiqui
Hussain Ahmed Siddiqui

Posted on

JOTAI(GLOBAL STATE MANGEMENT)

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.

Image description

Use the atom in your components
It can be used like React.useState:

Image description

for more details: https://jotai.org/

Top comments (0)