Search code examples
react-nativereact-native-reanimated

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.


Solution

  • 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/