jotai icon indicating copy to clipboard operation
jotai copied to clipboard

improve useAtomsSnapshot / useGotoAtomsSnapshot

Open dai-shi opened this issue 3 years ago • 7 comments

Found some issues while developing #837:

  • [x] Ignore snapshots with invalidated atoms
  • [ ] Avoid extra re-renders
  • [x] Maybe we should somehow return dependents too. (Provider's useDebugState does it)
  • [x] Support versionedWrite in useGotoAtomsSnapshot (See useAtomsDevtools.ts)

We would need to write tests too.

dai-shi avatar Dec 28 '21 02:12 dai-shi

Good idea!

Thisen avatar Jan 01 '22 12:01 Thisen

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 avatar Jan 03 '22 20:01 Thiesl137

@Thiesl137 That would be great! Please also keep #918 posted for any updates or even no updates.

dai-shi avatar Jan 03 '22 23:01 dai-shi

@Thiesl137 Let's close this, but your help would be so appreciated, so feel free to re-open it!

Aslemammad avatar Mar 31 '22 03:03 Aslemammad

@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 avatar Mar 31 '22 09:03 dai-shi

@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!

Aslemammad avatar Apr 01 '22 10:04 Aslemammad

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.

dai-shi avatar Jul 23 '22 00:07 dai-shi