react-joint-hooks

1.0.1 • Public • Published

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>
}

Package Sidebar

Install

npm i react-joint-hooks

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

11.6 kB

Total Files

13

Last publish

Collaborators

  • nearimba