react-spring
react-spring copied to clipboard
[bug]: useSpring cause React warning and error on server-side-render
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
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.