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

Better fix for StrictMode #1473

Closed
wants to merge 2 commits into from

Conversation

drarmstr
Copy link
Contributor

@drarmstr drarmstr commented Dec 1, 2021

Summary: A better fix for React StrictMode. Instead of maintaining a ref in <RecoilRoot> for the set of atoms to re-initialize we will just keep the atoms in knownAtoms even when they are cleaned up. This way we maintain the set of known atoms we need to re-initialize. However, we have to be careful to ensure the we actually re-initialize the atom when the effect runs again, even if it is already in knownAtoms. We also have to be careful when using an initialized atom in a Snapshot that it does not try to re-initialize.

Differential Revision: D32751941

@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 Dec 1, 2021
@facebook-github-bot
Copy link
Contributor

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

@drarmstr drarmstr added the bug Something isn't working label Dec 1, 2021
@drarmstr drarmstr self-assigned this Dec 1, 2021
drarmstr added a commit to drarmstr/Recoil that referenced this pull request Dec 6, 2021
Summary:
Pull Request resolved: facebookexperimental#1473

A better fix for React StrictMode.  Instead of maintaining a ref in `<RecoilRoot>` for the set of atoms to re-initialize we will just keep the atoms in `knownAtoms` even when they are cleaned up.  This way we maintain the set of known atoms we need to re-initialize.  However, we have to be careful to ensure the we actually re-initialize the atom when the effect runs again, even if it is already in `knownAtoms`.  We also have to be careful when using an initialized atom in a `Snapshot` that it does not try to re-initialize.

Differential Revision: D32751941

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

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

drarmstr added a commit to drarmstr/Recoil that referenced this pull request Dec 8, 2021
Summary:
Pull Request resolved: facebookexperimental#1473

A better fix for React StrictMode.  Instead of maintaining a ref in `<RecoilRoot>` for the set of atoms to re-initialize we will just keep the atoms in `knownAtoms` even when they are cleaned up.  This way we maintain the set of known atoms we need to re-initialize.  However, we have to be careful to ensure the we actually re-initialize the atom when the effect runs again, even if it is already in `knownAtoms`.  We also have to be careful when using an initialized atom in a `Snapshot` that it does not try to re-initialize.

Reviewed By: davidmccabe

Differential Revision: D32751941

fbshipit-source-id: 2ebea0aba135f9194715a447170ae692815ece1d
@facebook-github-bot
Copy link
Contributor

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

Summary:
Pull Request resolved: facebookexperimental#1451

Automate testing React StrictMode and beef up tests to pass or skip in that environment.

NOTE: Garbage collection tests are currently failing with atoms being retained when they shouldn't be in StrictMode

Differential Revision: https://www.internalfb.com/diff/D32605982?entry_point=27

fbshipit-source-id: 4b99c388b088d3360ef1658fe53aaacf324cdd9a
Summary:
Pull Request resolved: facebookexperimental#1473

A better fix for React StrictMode.  Instead of maintaining a ref in `<RecoilRoot>` for the set of atoms to re-initialize we will just keep the atoms in `knownAtoms` even when they are cleaned up.  This way we maintain the set of known atoms we need to re-initialize.  However, we have to be careful to ensure the we actually re-initialize the atom when the effect runs again, even if it is already in `knownAtoms`.  We also have to be careful when using an initialized atom in a `Snapshot` that it does not try to re-initialize.

Reviewed By: davidmccabe

Differential Revision: D32751941

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

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

@drarmstr drarmstr deleted the export-D32751941 branch December 20, 2021 23:39
AlexGuz23 pushed a commit to AlexGuz23/Recoil that referenced this pull request Nov 3, 2022
Summary:
Pull Request resolved: facebookexperimental/Recoil#1473

A better fix for React StrictMode.  Instead of maintaining a ref in `<RecoilRoot>` for the set of atoms to re-initialize we will just keep the atoms in `knownAtoms` even when they are cleaned up.  This way we maintain the set of known atoms we need to re-initialize.  However, we have to be careful to ensure the we actually re-initialize the atom when the effect runs again, even if it is already in `knownAtoms`.  We also have to be careful when using an initialized atom in a `Snapshot` that it does not try to re-initialize.

Reviewed By: davidmccabe

Differential Revision: D32751941

fbshipit-source-id: 7b36a6c6ed344cc899b48d649ea9dafff5af004c
snipershooter0701 pushed a commit to snipershooter0701/Recoil that referenced this pull request Mar 5, 2023
Summary:
Pull Request resolved: facebookexperimental/Recoil#1473

A better fix for React StrictMode.  Instead of maintaining a ref in `<RecoilRoot>` for the set of atoms to re-initialize we will just keep the atoms in `knownAtoms` even when they are cleaned up.  This way we maintain the set of known atoms we need to re-initialize.  However, we have to be careful to ensure the we actually re-initialize the atom when the effect runs again, even if it is already in `knownAtoms`.  We also have to be careful when using an initialized atom in a `Snapshot` that it does not try to re-initialize.

Reviewed By: davidmccabe

Differential Revision: D32751941

fbshipit-source-id: 7b36a6c6ed344cc899b48d649ea9dafff5af004c
eagle2722 added a commit to eagle2722/Recoil that referenced this pull request Sep 21, 2024
Summary:
Pull Request resolved: facebookexperimental/Recoil#1473

A better fix for React StrictMode.  Instead of maintaining a ref in `<RecoilRoot>` for the set of atoms to re-initialize we will just keep the atoms in `knownAtoms` even when they are cleaned up.  This way we maintain the set of known atoms we need to re-initialize.  However, we have to be careful to ensure the we actually re-initialize the atom when the effect runs again, even if it is already in `knownAtoms`.  We also have to be careful when using an initialized atom in a `Snapshot` that it does not try to re-initialize.

Reviewed By: davidmccabe

Differential Revision: D32751941

fbshipit-source-id: 7b36a6c6ed344cc899b48d649ea9dafff5af004c
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working 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