LoginSignup
1
0

jotaiのuseAtom()で更新関数の型がnever

Posted at

状態管理ライブラリjotaiを使ってみて、最初にはまったところのメモ

やりたいこと

useAtom()を使って値を更新

const [loading, setLoading] = useAtom<boolean>(loadingState);

return (
    <Button onClick={() => setLoading(!loading)}>button</Button>
  );

すると型 'never' には呼び出しシグネチャがありません。と言われる
image.png

neverだ
image.png

結論

型を書かない

const [loading, setLoading] = useAtom(loadingState);

なんでかな

1
0
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0