Closed janlin002 closed 1 year ago
https://codesandbox.io/s/github/jotai-labs/jotai-signal/tree/main/examples/01_typescript?file=/src/App.tsx Just opened it and it seems to be working. Can you modify it to reproduce the error?
I have solved the problem. I realized that I imported useAtom
and useSetAtom
incorrectly, I wrote jotai
instead of jotai/react
.
Hmm? Wouldn't it be the same?
import { useAtom } from 'jotai';
import { useAtom } from 'jotai/react';
https://codesandbox.io/s/recursing-cray-j0c9uc?file=/src/App.js
This is a simple demo and I noticed that if I use "$" like a useState hook(const [a, b] = useAtom(initvalue)
), it will result in an error(Invalid value used as weak map key
). However, if I declare them separately, it works correctly.
You want to pass an atom object to $()
, so in your case, it's $(initCount)
.
Understood, thank you for your response.
I'm trying to follow a tutorial, but I encountered the following problem: "Invalid value used as weak map key". How can I solve this issue?