Creating and using global state
Create the state and use it within and outside of a React component. Few lines of code. No boilerplate!SSR
The state is created by createState. The first argument is the initial state value. The result value is an instance of State, which can be used directly to get and set the state value outside of a React component.
When you need to use the state in a functional React component, pass the created state to useState function and use the returned result in the component's logic. The returned result is an instance of State too, which must be used within a React component (during rendering or in effects) and/or it's children components.