Setup
Reatom is a framework-agnostic state manager, meaning you can use it with various adapters for different frameworks. This guide focuses on using Reatom with React.js, as it’s currently the most popular view library.
Create new project from template
#The base template project includes Vite, TypeScript, React and Reatom ecosystem. You can check in out here
You can also try it online:
To setup it in your machine you can use the degit package.
Add to existing project
#With React
#Installation
#You need to set up the main context and wrap your application in a provider at the top level.
Usage
#The useAtom
function lets you manage state similar to useState
, but with the added benefit of shared atom state.
Additionally, you can create computed atoms (similar to selectors) directly inside useAtom
.
This is just the basic functionality of reatom-react bindings. For more details, check out the @reatom/npm-react package documentation.