Closed astoilkov closed 2 years ago
After some research, here are some candidate tasks:
useSyncExternalStore
useSyncExternalStore
should handle all that now.activeHooks
and force updating all other hooks with the same key
. useSyncExternalStore
will also handle this.After some research, here are some candidate tasks:
- [ ] implementation should be based on
useSyncExternalStore
- [ ] remove manual handling of hydration mismatches.
useSyncExternalStore
should handle all that now.- [ ] remove manual handling of
activeHooks
and force updating all other hooks with the samekey
.useSyncExternalStore
will also handle this.- [ ] update tests
- [ ] add tests that test support for concurrent rendering
- [ ] decide what to do with older versions. it seems like support for both <= v17 and v18 with the same code will have some drawbacks. I should see what will be the most appropriate way to support both versions.
For the last one, React team seems to provide a backwards compatible shim for useSyncExternalStore
(see this npm package). Is this suitable here?
@ha-ku Yes, it is. However, I'm concerned the shim will double the bundle size of the hook which isn't a no-go but it is something worth considering.
@ha-ku Yes, it is. However, I'm concerned the shim will double the bundle size of the hook which isn't a no-go but it is something worth considering.
Indeed. Maybe the way to find the answer is simply making a test version with the shim. Then we'll find out how much the bundle size get influenced. Of cource, this should be something after the implementation with useSyncExternalStore
getting finished.
Yep, I totally agree. I will do some experiments and probably publish a beta version on npm.
This is now complete. The new version supports React 18. Closing this.
Hi @astoilkov will you keep providing support for React 17?
Thanks again
@martinsantibanez Yes. I will be helping people if they have problems. I will make fixes. I am also willing to implement new small features — nothing big.
I will use this issue to track the progress of implementing React 18 support for this hook. For now, I know of one bug that exists when the new concurrent renderer is enabled.
I will post any progress here.