react-v2
@reatom/react-v2
#React bindings package for Reatom store.
Reatom is declarative and reactive state manager, designed for both simple and complex applications. See docs.
Install
#or
@reatom/react-v2
depends on and works with@reatom/core-v2
andreact
. You should install this packages too.
Hooks Api
#If you use React 16 or 17 you should setup batch bindings for React by yourself. Just import @reatom/react-v2/react-dom-batched-updates
or @reatom/react-v2/react-native-batched-updates
on the top (root) of your project to make it work before any hook call.
useAtom
#Connects the atom to the store represented in context and returns the state of the atom from the store (or default atom state).
Basic (useAtom)
#Depended value by selector
#useAction
#Binds action with dispatch to the store provided in the context.
Basic (useAction)
#Prepare payload for dispatch
#Conditional dispatch
#If action creator don’t return an action dispatch not calling.
Usage
#Step 0 - OPTIONAL. Create store.
#This step is required only for SSR, when one node.js process may handle a few requests at the time.