react-native-reanimated icon indicating copy to clipboard operation
react-native-reanimated copied to clipboard

Export namespace should be first transformed by `@babel/plugin-proposal-export-namespace-from` on `export * as default from './Animated';`

Open tomekzaw opened this issue 2 years ago • 2 comments

Description

Starting from Reanimated 2.9.0, if you forget to add Reanimated's Babel plugin, instead of a user-friendly error message, the following error will appear:

error: node_modules/react-native-reanimated/src/index.ts: /Users/tomekzaw/RNOS/Issue3397/node_modules/react-native-reanimated/src/index.ts: Export namespace should be first transformed by `@babel/plugin-proposal-export-namespace-from`.
  5 | export * from './reanimated1';
  6 | export * from './reanimated2';
> 7 | export * as default from './Animated';
    |        ^^^^^^^^^^^^
  8 |
Android iOS
iOS error Android error

funny meme

Solution

  1. Add Reanimated's babel plugin to your babel.config.js:
module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
+  plugins: ['react-native-reanimated/plugin'],
};
  1. Clear application cache (depending on your workflow or favourite package manager):
  • yarn start --reset-cache
  • OR: npm start -- --reset-cache
  • OR: expo start -c
  1. Reload app

See installation docs for more details.

Disclaimer

Obviously, we need to restore the original user-friendly error message:

  • https://github.com/software-mansion/react-native-reanimated/pull/3437

tomekzaw avatar Jul 26 '22 11:07 tomekzaw

Bro you saved my life ! Thank you :)

DiyarYelbaka avatar Jul 30 '22 15:07 DiyarYelbaka

Thank you for this! was about to pull my hair out

justindc100 avatar Aug 01 '22 22:08 justindc100

Brilliant, thanks folks

PerryRylance avatar Aug 24 '22 11:08 PerryRylance

Hello friend, it works quite well for me. Thank you for your contribution and help, greetings! :+1:

jdc0092 avatar Sep 28 '22 19:09 jdc0092