Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Workaround React renderers without useSyncExternalStore() support #2001

Closed

Conversation

drarmstr
Copy link
Contributor

@drarmstr drarmstr commented Sep 7, 2022

Summary: Recoil will attemp to detect if useSyncExternalStore() is supported before calling it. However, sometimes the host environment supports it but creates additional React renderers, such as with react-three-fiber, which do not. Since React goes through a proxy dispatcher we can't simply check if useSyncExternalStore() is defined. Thus, this workaround will catch the situation and fallback to using useState() and useEffect().

Differential Revision: D39329856

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported labels Sep 7, 2022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39329856

…ort (facebookexperimental#2001)

Summary:
Pull Request resolved: facebookexperimental#2001

Recoil will attemp to detect if `useSyncExternalStore()` is supported before calling it.  However, sometimes the host environment supports it but creates additional React renderers, such as with `react-three-fiber`, which do not.  Since React goes through a proxy dispatcher we can't simply check if `useSyncExternalStore()` is defined.  Thus, this workaround will catch the situation and fallback to using `useState()` and `useEffect()`.

Differential Revision: D39329856

fbshipit-source-id: 564cd38392902fbd56c8a1b10cb99450bfe282a4
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39329856

@drarmstr drarmstr self-assigned this Sep 16, 2022
@drarmstr drarmstr deleted the export-D39329856 branch September 16, 2022 22:03
snipershooter0701 pushed a commit to snipershooter0701/Recoil that referenced this pull request Mar 5, 2023
…ort (#2001)

Summary:
Pull Request resolved: facebookexperimental/Recoil#2001

Recoil will attemp to detect if `useSyncExternalStore()` is supported before calling it.  However, sometimes the host environment supports it but creates additional React renderers, such as with `react-three-fiber`, which do not.  Since React goes through a proxy dispatcher we can't simply check if `useSyncExternalStore()` is defined.  Thus, this workaround will catch the situation and fallback to using `useState()` and `useEffect()`.

Reviewed By: habond

Differential Revision: D39329856

fbshipit-source-id: 6e4e853d4f3d758b4171ac49cab9fbb1170f66b4
eagle2722 added a commit to eagle2722/Recoil that referenced this pull request Sep 21, 2024
…ort (#2001)

Summary:
Pull Request resolved: facebookexperimental/Recoil#2001

Recoil will attemp to detect if `useSyncExternalStore()` is supported before calling it.  However, sometimes the host environment supports it but creates additional React renderers, such as with `react-three-fiber`, which do not.  Since React goes through a proxy dispatcher we can't simply check if `useSyncExternalStore()` is defined.  Thus, this workaround will catch the situation and fallback to using `useState()` and `useEffect()`.

Reviewed By: habond

Differential Revision: D39329856

fbshipit-source-id: 6e4e853d4f3d758b4171ac49cab9fbb1170f66b4
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants