react-spring
react-spring copied to clipboard
[bug]: Re-render in first render breaks useSpring hook
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.4.4
What's Wrong?
When a component re-render in first render useSpring doesn't work.
I understand that this behavior of the component is not quite right. But we have a place where we can't fix it and that's where useSpring breaks.
To Reproduce
See the exmaple: https://codesandbox.io/s/admiring-oskar-wl3b8m?file=/src/App.tsx:208-272
This code is key:
const [x, set] = useState(1);
if (x === 1) {
set(2);
}
Expected Behaviour
useSpring should works fine
Link to repo
https://codesandbox.io/s/admiring-oskar-wl3b8m?file=/src/App.tsx:208-272