react-spring icon indicating copy to clipboard operation
react-spring copied to clipboard

[bug]: useSpring cause React warning and error on server-side-render

Open hze94 opened this issue 2 years ago • 1 comments

Which react-spring target are you using?

  • [X] @react-spring/web
  • [ ] @react-spring/three
  • [ ] @react-spring/native
  • [ ] @react-spring/konva
  • [ ] @react-spring/zdog

What version of react-spring are you using?

9.7.5

What's Wrong?

I use useSpring on server-side-render, and get some error:

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.
Error generating stack: Cannot add property prepareStackTrace, object is not extensible
TypeError: Cannot add property prepareStackTrace, object is not extensible

To Reproduce

I use useSpring in my component look like this:

const [springStyles, api] = useSpring(() => ({
   from: { height: 0 },
 }));

Expected Behaviour

fix this error

Link to repo

hze94 avatar Nov 11 '24 04:11 hze94

There's not enough information nor a repo to look into this issue, we can reopen this when there's more information available incl. a reproduction of the issue.

joshuaellis avatar Nov 11 '24 08:11 joshuaellis