Coding for Global State
Explore some coding for a basic global state solution with React Hooks.
Building blocks for global state using Hooks
Discover what is needed to build the global state solution using useReducer
and useContext
:
- Initial State
- A reducer function
- Global state object and the dispatch function
- A Store Context with Provider
Initial State
The initial state can simply be defined as a JavaScript object. An example is shown below. A global state with the ...