You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When updating state as part of render code (ugh), if it causes a component that uses react-spring to re-render, useSpring will return undefined on the second render.
I know updating state directly as part of render code can be bad. This was discovered when working with some older code written by someone newer to react. 😅
This started happening after upgrading from version 9.0.0-canary.808.17.55c5691 to the most recent v9.0.0-rc.3, so the break happened somewhere in there.
(You might have to refresh the live demo to get the console logs to start showing)
The quick fix is, of course, to follow good practices and not update your state during the render cycle, like with a useEffect (shown in the sandbox). But since this started happening between versions, I figured it was a bug somewhere in the recent v9 versions.
As a note, this bug can be caused by anything updating state in their render code (component or hook), as long as it causes whatever component is using react-spring to also re-render.
Also described in #1046 (it's a different issue, though, I think)
The text was updated successfully, but these errors were encountered:
zachintosh
changed the title
[V9-rc.3] When state is updated in render code, it causes useSpring to return undefined
[v9.0.0-rc.3] When state is updated in render code, it causes useSpring to return undefined
Jul 29, 2020
When updating state as part of render code (ugh), if it causes a component that uses react-spring to re-render, useSpring will return undefined on the second render.
I know updating state directly as part of render code can be bad. This was discovered when working with some older code written by someone newer to react. 😅
This started happening after upgrading from version
9.0.0-canary.808.17.55c5691
to the most recentv9.0.0-rc.3
, so the break happened somewhere in there.Here's a sandbox reproducing the issue:
https://codesandbox.io/s/elastic-sky-xthi0?file=/src/App.js
(You might have to refresh the live demo to get the console logs to start showing)
The quick fix is, of course, to follow good practices and not update your state during the render cycle, like with a useEffect (shown in the sandbox). But since this started happening between versions, I figured it was a bug somewhere in the recent v9 versions.
As a note, this bug can be caused by anything updating state in their render code (component or hook), as long as it causes whatever component is using react-spring to also re-render.
Also described in #1046 (it's a different issue, though, I think)
The text was updated successfully, but these errors were encountered: