jotai
jotai copied to clipboard
improve useAtomsSnapshot / useGotoAtomsSnapshot
Found some issues while developing #837:
- [x] Ignore snapshots with invalidated atoms
- [ ] Avoid extra re-renders
- [x] Maybe we should somehow return
dependentstoo. (Provider's useDebugState does it) - [x] Support versionedWrite in useGotoAtomsSnapshot (See useAtomsDevtools.ts)
We would need to write tests too.
Good idea!
I'm going through the code-base of Atomic this week. My time has opened up this month to get the product features using snapshots to the chrome store. I'll post here if I have any feedback on improvement.
@Thiesl137 That would be great! Please also keep #918 posted for any updates or even no updates.
@Thiesl137 Let's close this, but your help would be so appreciated, so feel free to re-open it!
@Aslemammad Actually, I have some ideas written in the description to improve, without having @Thiesl137 feedback. So, let's do them. Would you like to work on this?
@dai-shi I'd be happy, but it'd be good if you good them somewhere in my priority list! so I can work on it soon!
Avoid extra re-renders
Currently, useAtomsSnapshot has this:
https://github.com/pmndrs/jotai/blob/0682db6e94efe38d4f4d36ff0a0e4ef8b004aad7/src/devtools/useAtomsSnapshot.ts#L38-L41
which can cause extra re-renders when nothing changes.
useAtomsDevtools has a guard for it:
https://github.com/pmndrs/jotai/blob/0682db6e94efe38d4f4d36ff0a0e4ef8b004aad7/src/devtools/useAtomsDevtools.ts#L128-L137
see "bail out" condition.