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

fix: useEffect when SSR #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Kerumen
Copy link

@Kerumen Kerumen commented Nov 6, 2020

When SSR, useLayoutEffect prints a warning. This PR fixes this by swapping the hook with a useEffect if we are on the server. This is a common way to solve this problem:

Screenshot 2020-11-06 at 11 00 15

@mysterybear
Copy link

+1 on this, makes a lot of noise in the log when developing with Next.js

@gsimone
Copy link
Collaborator

gsimone commented Feb 19, 2021

@mysterybear can you test the PR and give feedback? I'll merge then 👍

@mysterybear
Copy link

mysterybear commented Feb 19, 2021

Hi @gsimone thanks for quick reply, I've tested using JS and it seems to work fine here: https://codesandbox.io/s/github/mysterybear/tweaks-next-ssr-use-effect-test?file=/pages/index.js

I just took the example codesandbox code and pasted it into a Next.js project and pointed use-tweaks at the patch author's branch, hope that's okay

Edit: wanted to try with TS too, but getting the same problem as #43 even with v0.3.1

@enzoferey
Copy link

Any chance this gets ever merged ?

@gsimone
Copy link
Collaborator

gsimone commented Jun 7, 2021

Hey @enzoferey (and @mysterybear), we pretty much moved all efforts to https://github.com/pmndrs/leva; if you want to help with use-tweaks, let me know and I can make you maintainer 👍

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.

4 participants