fre
fre copied to clipboard
Support for new React 18 hook - useSyncExternalStore
I just wanted to put this as a place holder item for now
- https://github.com/reactwg/react-18/discussions/86
Some libraries that are using useSyncExternalStore already:
react-query: https://github.com/tannerlinsley/react-query/pull/3064/files
Hi @cliffordfajardo, Here we need to explain in detail:
API level compatibility is not difficult, and the shim is also applicable to fre.
https://github.com/yisar/fre/blob/master/demo/src/use-sync-external-store.tsx
In addition to API compatibility, useSyncExternalStore internal implementation mainly solves the tearing problem, which is a defect of Concurrent mode.
React uses this API to degrade the internal scheduling to micro tasks, which loses the concurrency ability, but ensures the consistency of rendering.
Fre has the same defect. It may be useful to implement this API, but I don't think many libraries will use it in the short term.
Came here because I wanted to use Xstate with a react alternative library. So that could be a use case. The @xstate/react package uses useSyncExternalStore