Justin Priede
Justin Priede

Reputation: 119

Reanimated 2 failed to create a worklet — Maybe You Forgot to Add Reanimated’s babel Plugin?

I have tried all I can think of to fix this error. I have tried uninstalling reanimated-bottom-sheet and react-native-reanimated and reinstalling them. Clearing cache. I do not have a babel.config.js file that I am aware of to edit. I know the error comes from this exact import below.

import BottomSheet from 'reanimated-bottom-sheet';

I have also linked a repository in order to reproduce my exact issue here. I added my node_modules just in case, I am not sure if it would help someone see what I was doing wrong or not.

Upvotes: 2

Views: 10379

Answers (4)

Israël Mekomou
Israël Mekomou

Reputation: 125

If using expo, use

expo install react-native-reanimated react-native-gesture-handler

instead of

yarn add react-native-reanimated react-native-gesture-handler

and then exit server then run expo r -c This worked for me.

Upvotes: 0

Aeo-dev
Aeo-dev

Reputation: 1

__reanimatedWorkletInit function and __worklet property have been removed in [email protected].

Check reanimated releases https://github.com/software-mansion/react-native-reanimated/releases.

In my case i just downgraded to [email protected] and it worked fine

Upvotes: 0

chenop
chenop

Reputation: 5143

I added 'react-native-reanimated/plugin' to babel.config.js - but I had also .babelrc... stay with only one of them...

Upvotes: 0

Sergey Zhukov
Sergey Zhukov

Reputation: 534

You need to add babel.config.js in root directory of the project (near package.json) with following context (or just grab it from https://github.com/software-mansion-labs/reanimated-2-playground):

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    'react-native-reanimated/plugin',
  ],
};

Check reanimated docs https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/installation/

Upvotes: 4

Related Questions