Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 537 Bytes

File metadata and controls

26 lines (18 loc) · 537 Bytes

Home

Creating React Hook

The createHookFromStore factory is a utility for creating React hooks from stores.

Creating Hooks

import { createStore } from '@yobta/stores'
import { createHookFromStore } from '@yobta/stores/react'

const myStore = createStore(1)
export const useMyStore = createHookFromStore(myStore)

Using Hooks

import { useMyStore } from './my-store'

export const myComponent = () => {
  let myValue = useMyStore()
  return <>My value is: {myValue}</>
}