Skip to content

Get access to a global store with just hooks, no Redux or message passing.

Notifications You must be signed in to change notification settings

MinimumViablePerson/useStore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

useStore

Get access to a global store with just hooks, no Redux or message passing.

How to install

npm i @mvps@usestore

How to use

import useStore from '@mvps/usestore'

const App = props => {
  // you can set the initial state in the first call:
  const [count, setCount] = useStore('count', 0)
  
  return <h1>{count}</h1>
}

// then, in any other component, just retrieve the value from the store:

import useStore from '@mvps/usestore'

const Counter = props => {
  const [count, setCount] = useStore('count')
  
  return <h1>{count}</h1>
}

Have fun!

About

Get access to a global store with just hooks, no Redux or message passing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published