Closed yf-yang closed 10 months ago
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 93f87be17468d790d9920d40b8595d910ab0fe38:
Sandbox | Source |
---|---|
React | Configuration |
React TypeScript | Configuration |
Hi, I think you can become a maintainer of jotai-scope. I just sent an invitation.
This solution is still incomplete. I write another example 06 to illustrate it. When 06 get fixed, we can guarantee both write and read are correct.
To give it a try, use [
pnpm add
,yarn add
,npm i
] https://pkg.csb.dev/pmndrs/jotai/commit/3185a131/jotai
I see. You can change package.json if you want.
@dai-shi any comments?
Yes, ready to release.
Do you want to release? I can tell you my workflow. Or, I can do it this time, no problem. Whichever you want.
Hmmm, then would you please tell me the workflow? I'm interested in it.
Seems to be:
npm publish --access public
fixes #16, #17 depends on https://github.com/pmndrs/jotai/pull/2356 To give it a try, use [
pnpm add
,yarn add
,npm i
] https://pkg.csb.dev/pmndrs/jotai/commit/3b6440d1/jotaiRoot Cause Analysis
Take a look of this atom:
Note that the condition
myAtom === anAtom
evals to true, which means they are exactly the same atom. Then, whydispatch(action)
callsreducer(action)
, butset(anAtom, reducedValue)
directly updates the value ofanAtom
instead of callingreducer(reducedValue)
?The key is here: https://github.com/pmndrs/jotai/blob/b5c38081e922b56621c6da9b9c32ef3d0f46e4b3/src/vanilla/store.ts#L527,
a === atom
checkThe line (
a === atom
check) checks if an atom is setting itself, so instead of calling the setter again, it directly update the value.TODO