Atoms sometimes cause updates to dependencies even when their value remains the same
MasonD opened this issue · comments
Mason Dechaineux commented
Summary
As per discussion with Daishi in the poimandres discord. In certain atom configurations, a derived atom will cause its dependencies to recalculate even if its value is identical to its previous value. It seems to be when
- a derived atom A which we expect to keep the same
- is used by another derived atom B
- which is further used by another derived atom C which has other dependencies that change at the same time as A's dependencies.
This causes B to recalculate even though A's value remains the same
Link to reproduction
https://codesandbox.io/s/atomstate-d-changes-vz9p5f?file=/src/App.tsx
Daishi Kato commented
https://codesandbox.io/s/atomstate-d-changes-forked-jmv4mr
v1 works as expected.
Daishi Kato commented
#2016 should fix it: https://codesandbox.io/s/atomstate-d-changes-5gmk8z