Use Atom Creator

简单地在React组件级别创建atom并使用

快速上手

安装依赖

npm
yarn
pnpm
bun
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>
  );
};