bvaughn / react-resizable-panels

https://react-resizable-panels.vercel.app/
MIT License
3.73k stars 131 forks source link

Warning during SSR due to useLayoutEffect #53

Closed asterikx closed 1 year ago

asterikx commented 1 year ago

Hi @bvaughn, thanks for this amazing library!

I get a warning due to the use of useLayoutEffect in this library during SSR using Next.js:

Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.
    at $4b51bd7b90b9da8b$export$2e2bcd8739ae039 (/Users/erikmuller/cnapp/node_modules/react-resizable-panels/dist/react-resizable-panels.js:29:63)

Is it possible to use something like useIsomorphicLayoutEffect instead of useLayoutEffect?

bvaughn commented 1 year ago

Ah, that's fair. PanelGroup doesn't have enough information to render panels correctly until they've mounted and registered but I could use a default flex: 1 1 auto style for the initial render.

bvaughn commented 1 year ago

Try 0.0.28