Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for new React 18 hook - useSyncExternalStore #328

Open
cliffordfajardo opened this issue Dec 7, 2021 · 2 comments
Open

Support for new React 18 hook - useSyncExternalStore #328

cliffordfajardo opened this issue Dec 7, 2021 · 2 comments

Comments

@cliffordfajardo
Copy link

I just wanted to put this as a place holder item for now

Some libraries that are using useSyncExternalStore already:

@yisar
Copy link
Collaborator

yisar commented Dec 8, 2021

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.

@herrKlein
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants