devel0 / example-react-global-state

example react global state

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

example react global state

description

Shows usage of react-hookstore library to manage global state across multiple components.

LIVE DEMO

notes:

  • clicking on a component change global state hooked and attached to all other components that make usage of useStore
  • each store can have different name and backing type
  • stores created toplevel at App.tsx
  • an helper function allow to change after a cloneDeep to manage complex state objects

how this project was built

yarn create react-app example-react-global-state --template typescript
cd example-react-global-state/
yarn add react-hookstore lodash @types/lodash
echo "BROWSER=none" > .env
code .
yarn start
  • hit F5
  • choose Chrome
  • set on launch.json startup url "url": "http://localhost:3000",
  • F5 again

About

example react global state

License:MIT License


Languages

Language:TypeScript 76.9%Language:HTML 14.9%Language:CSS 8.1%Language:Shell 0.1%