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