@whitetrefoil/use-link-atom
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@whitetrefoil/use-link-atom

A tiny helper to link Jotai's useAtom / useSetAtom & events.

Usage

import {useLinkAtom, useLinkSetAtom} from '@whitetrefoil/use-link-atom'
import {atom} from 'jotai/vanilla'


const valAtom = atom('')
const countAtom = atom(0)

const MyElem = () => {
  const [val, setVal, linkVal] = useLinkAtom(valAtom)
  const [setCount, linkCount] = useLinkSetAtom(countAtom)
  return <>
    <input type="text" value={val} onChange={linkVal}/>
    <input type="number" defaultValue={0} onChange={linkCount}/>
  </>
}

Readme

Keywords

Package Sidebar

Install

npm i @whitetrefoil/use-link-atom

Weekly Downloads

0

Version

0.1.1

License

Unlicense

Unpacked Size

5.72 kB

Total Files

8

Last publish

Collaborators

  • whitetrefoil