Search Docs
简单地在React组件级别创建atom并使用
npm install use-atom-creator
const App = () => { const countAtom = useAtomCreator(0); const [count, setCount] = useAtom(countAtom); return ( <div> {count} <button onClick={() => setCount(count + 1)}>+</button> </div> ); };