Package Exports
- create-global-state-hook
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (create-global-state-hook) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
crete-global-state-hook
Creates a hook like useState but all instances will have a single shared storage
Example
import creteGlobalStateHook from 'crete-global-state-hook'
const useGlobalCounter = createGlobalStateHook(0)
export default function GlobalCounter() {
const [count, setCount] = useGlobalCounter()
return (
<div>
<input type="button" value="-" onClick={() => setCount(count - 1)} />
{count}
<input type="button" value="+" onClick={() => setCount(count + 1)} />
</div>
)
}