tweakpane / use-tweaks

🎛️ Tweak React components with Tweakpane
https://codesandbox.io/s/use-tweaks-example-58e02
MIT License
768 stars 23 forks source link

fix: useEffect when SSR #37

Open Kerumen opened 3 years ago

Kerumen commented 3 years ago

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 commented 3 years ago

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

gsimone commented 3 years ago

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

mysterybear commented 3 years ago

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 commented 3 years ago

Any chance this gets ever merged ?

gsimone commented 3 years ago

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 👍