react-native-reanimated-carousel: Reanimated global.__reanimatedWorkletInit is not a function
Describe the bug
When i try use library with Expo, the follow message shows
TypeError: global.__reanimatedWorkletInit is not a function. (In 'global.__reanimatedWorkletInit(_f)', 'global.__reanimatedWorkletInit' is undefined)
If i put the code
global.__reanimatedWorkletInit = () => {};
on '…/lib/commonjs/utils/dealWithAnimation.js works correctly
To Reproduce Steps to reproduce the behavior:
- Install library and try use
- See error
Screenshots
Versions:
- expo: ~45.0.0
- react: v17.0.2
- react-native: v0.68.1
- react-native-reanimated: v^2.8.0
- react-native-reanimated-carousel: v^2.3.10
- react-native-gesture-handler: v~2.2.0
Smartphone:
- Device: iPhoneXR
- OS: iOS 15.4
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 9
- Comments: 33 (7 by maintainers)
Commits related to this issue
- Fixing the react-native-reanimated-carousel error https://github.com/dohooo/react-native-reanimated-carousel/issues/182 — committed to litentry/archived-litentry-mobile-app by deleted user 2 years ago
- Issue-1145 Adding active account state (#1210) * Fixing the react-native-reanimated-carousel error https://github.com/dohooo/react-native-reanimated-carousel/issues/182 * Adding active account st... — committed to litentry/archived-litentry-mobile-app by deleted user 2 years ago
I add
global.__reanimatedWorkletInit = () => { };
to \node_modules\react-native-reanimated\src\Animated.js and the issue goneSame here!
I have the same problem
Same problem here. All debugging instructions are ineffective
I released it in 2.6.0.
This error is triggered by this PR, And there is related issue.
In version 2.7.0+,
__reanimatedWorkletInit
is deleted, so i added this code to my index file.I think this should work with different versions of
reanimated
. And this problem has been happening for too long. Sorry. I will reopen this issue if there is any problem. 🍺Im working with Expo SDK and it require react-native-reanimated 2.8.0. I know downgrade to Reanimated 2.6.0 the issues fix, but i want somehelp with react-native-reanimated 2.8.0. Pls fix it. Thanks you. @dohooo
patch did not work for me. Removing all calls to
global.__reanimatedWorkletInit()
innode_modules/react-native-reanimated-carousel/lib/commonjs/*
usingpatch-package
did the trick for now until a proper fix is made.@thanhtrung07 Maybe I’m stating the obvious but modifying a package in node_modules is not a very stable solution to any problem. The ‘fix’ will break when building to production, and it will not be added to your commits.
Having the same issue since update of expo SDK 45 Your fix is not working on my side
I patched reanimated package 2.8.0 (by patch-package) and it’s works for me:
this library is working fine on expo but it wasn’t working for me with nextjs, however adding this somewhere high up the hierarchy (e.g. App.tsx) fixed it:
I have the same problem. Reducing or upgrading the ‘react-native-reanimated’ version has no effect
same here. I tried using
import 'react-native-reanimated'
as suggested in: https://stackoverflow.com/questions/70750047/typeerror-global-reanimatedworkletinit-is-not-a-function-in-global-reani with no effect.