On web, with React's strict mode, animations don't work on first render #6264
Labels
Close when stale
This issue is going to be closed when there is no activity for a while
Platform: Web
This issue is specific to web
Repro provided
A reproduction with a snippet of code, snack or repo is provided
Description
If you use React's strict mode (e.g. you wrapped your components in
<React.StrictMode>
, or you are using next.js and havereactStrictMode: true
in yournext.config.js
, which is default for new apps created with create-next-app), animations won't work on web.Animations are broken until the component is rendered a second time.
It looks like the
SharedValue
is updating properly, but the animated style is not being properly applied to theAnimated.View
somehow.React's strict mode forces every component to be mounted->unmounted->mounted on every mount, and also forces
useEffect
s to be called twice, so it could be related to either of those.Steps to reproduce
(For the repro link below, the specific branch I linked is a react-native-reanimated only reproduction. The
main
branch also has a reproduction, using a gesture from react-native-gesture-handler to provide the animation.)Snack or a link to a repository
https://github.com/chriscoomber/RNGH-bugrepro-web-strictmode/tree/react-native-reanimated-issue
Reanimated version
3.10.1
React Native version
0.74.3
Platforms
Web
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
The text was updated successfully, but these errors were encountered: