react-joint-hooks
v1.0.1
Published
Simplest data sharing solution base on react hooks and subscribe/publish
Downloads
3
Readme
react-joint-hooks
The simplest data sharing base on react hooks and Subscribe/Publish
please view online demo
api
createJtStore
initialize an Joint store with key and initialization state
createJtStore<T>(key: string, state: T)
useJtStore
get value and method that can change this value
useJtStore<T>(key: string): [T, (a: T) => any] | never
example
import React from 'react'
import { createJtStore, useJtStore } from 'react-joint-hooks'
createJtStore('n', 1)
function Index() {
const [n, setNumber] = useJtStore('n')
return <div>
{n}
<button onClick={() => { setNumber(n + 1)}}>increase<button>
</div>
}