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

React 19 error: Update ScrollControls.tsx #2135

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

rgbjoy
Copy link

@rgbjoy rgbjoy commented Oct 23, 2024

Why

I receive this error when upgrading to React @ 19.0.0-rc-65a56d0e-20241020

You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it.

To address the issue of calling ReactDOM.createRoot() on a container that has already been passed to createRoot(), we can store the root instance and reuse it for rendering updates. I'm not sure how to go about this with different versions of React.

What

  • Root Instance Storage: A rootRef is used to store the root instance. This ensures that ReactDOM.createRoot() is only called once, and the same root instance is reused for subsequent renders.

  • Conditional Initialization: The root is initialized only if rootRef.current is null, preventing multiple initializations.

```You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it. ```
Copy link

vercel bot commented Oct 23, 2024

@rgbjoy is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

To address the issue of calling ReactDOM.createRoot() on a container that has already been passed to createRoot(), you should store the root instance and reuse it for rendering updates
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

Successfully merging this pull request may close these issues.

1 participant