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

Suppress useLayoutEffect warning #41

Merged
merged 1 commit into from
Aug 7, 2023
Merged

Suppress useLayoutEffect warning #41

merged 1 commit into from
Aug 7, 2023

Conversation

jcfilben
Copy link
Collaborator

@jcfilben jcfilben commented Aug 7, 2023

This PR suppresses the useLayoutEffect warning. This warning will be removed in the next version of React. For now this code is a temporary solution until the next version of react is released. See facebook/react#26395.

I also attempted a different solution where instead of suppressing the warning I replaced ReactDOMServer.renderToString with a method that uses createRoot and flushSync (solution can be found here: https://stackoverflow.com/questions/58181405/pass-a-react-component-to-leaflet-popup). This did fix the useLayoutEffect errors but I thought that the performance issues with flushSync were not worth it and we would be better off suppressing the warning.

Closes #37

@netlify
Copy link

netlify bot commented Aug 7, 2023

Deploy Preview for whimsical-moxie-6e43a0 ready!

Name Link
🔨 Latest commit 0a514c4
🔍 Latest deploy log https://app.netlify.com/sites/whimsical-moxie-6e43a0/deploys/64d145bb297fb80008de6694
😎 Deploy Preview https://deploy-preview-41--whimsical-moxie-6e43a0.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@jcfilben jcfilben requested a review from taysea August 7, 2023 19:28
@taysea
Copy link
Collaborator

taysea commented Aug 7, 2023

Thank you! This solution makes sense given it will be supported by React on its next release. Good notes re: performance downsides of the alternate approach.

@taysea taysea merged commit 66d3b5c into main Aug 7, 2023
@taysea taysea deleted the ignore-layout-warning branch August 7, 2023 19:43
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.

Investigate useLayoutEffect console error
2 participants