react-native-reanimated: [v3][Web] `setImmediate` is not defined
Description
This bug has appeared over the years many times. The solution has been to use requestAnimationFrame
instead of setImmediate
on Web.
The regression came from https://github.com/software-mansion/react-native-reanimated/pull/3970
See: https://github.com/software-mansion/react-native-reanimated/pull/2622 https://github.com/software-mansion/react-native-reanimated/pull/152.
Steps to reproduce
Use Reanimated on Next.js.
Snack or a link to a repository
https://stackblitz.com/edit/nextjs-pxczpl?file=pages%2Findex.js,next.config.js,package.json
Reanimated version
3.0.0
React Native version
0.71
Platforms
Web
JavaScript runtime
None
Workflow
None
Architecture
None
Build type
None
Device
None
Device model
No response
Acknowledgements
Yes
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (7 by maintainers)
Commits related to this issue
- Fix issue with setImmediate not defined on Web (#4276) ## Summary This PR removes uses of setImmediate which is not a standard API across web browsers. Instead, we use queueMicrotask API which is av... — committed to wordpress-mobile/react-native-reanimated by kmagiera a year ago
- Fix issue with setImmediate not defined on Web (#4276) ## Summary This PR removes uses of setImmediate which is not a standard API across web browsers. Instead, we use queueMicrotask API which is av... — committed to DrRefactor/react-native-reanimated by kmagiera a year ago
I solved this by:
npm i setimmediate
and before importing react-native-reanimated:However I’d prefer not to have this shim necessary
Adding
import “setimmediate”
in App.tsx root file solve my problem