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

Breaks using Strict Mode in React 18 #6

Open
bensaine opened this issue Feb 24, 2023 · 2 comments
Open

Breaks using Strict Mode in React 18 #6

bensaine opened this issue Feb 24, 2023 · 2 comments

Comments

@bensaine
Copy link

bensaine commented Feb 24, 2023

In React 18, this library does not work with Strict Mode in development mode.

React 18 introduces a change to Strict Mode which mounts and unmounts components.
See quoted section from React Docs:

With Strict Mode starting in React 18, whenever a component mounts in development, React will simulate immediately unmounting and remounting the component.

For some reason, this is breaking the library: Desmos expressions don't load properly. For example, if you put static <Expression> in <ScientificCalculator> (say "x=2"), the expression will load and quickly remove itself (probably because of the mount/unmount). However, dynamic <Expression>s containing some React state (that updates) work fine. The issue is solved when I remove Strict Mode, build for production, or downgrade to React 17. Thus it must be related to this new React 18 change.

I suspect it has to do with refs, and I found this issue. Many report similar symptoms: facebook/react#24670

Example:

<GraphingCalculator>
	<Expression id="function" latex="x^2" />
</GraphingCalculator>

Result (React 18, Strict Mode, development mode):
Result
x^2 appears but vanishes momentarily.

@danielfostiak
Copy link

I have this issue aswell, lmk if you found a fix please. For now i have just turned off strict mode

@elitebyte
Copy link

Also have these issue. Did you guys come up with a solution?

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