Minor Changes
-
#5302
809d8b5
Thanks @davidkpiano! - TheuseAtom
hook is now available for reading the value of an atom or selecting a value from the atom.const atom = createAtom(0); const Component = () => { const count = useAtom(atom); return ( <> <div onClick={() => atom.set((c) => c + 1)}>{count}</div> <button onClick={() => atom.set(0)}>Reset</button> </> ); };
With selectors:
const atom = createAtom({ count: 0 }); const Component = () => { const count = useAtom(atom, (s) => s.count); return <div>{count}</div>; };