react-nativebabeljsupgradepackager

Duplicate declaration "AnimatedComponent" Probably an internal error in react-native


I upgraded react-native from 0.48.4 to 0.51.0 After that I am getting this error. whenever I am running packager.Here is the console output

bundling failed: TypeError: /node_modules/react-native/Libraries/Animated/src/createAnimatedComponent.js: Duplicate declaration "AnimatedComponent" (This is an error on an internal node. Probably an internal error)
    at File.buildCodeFrameError (/node_modules/babel-core/lib/transformation/file/index.js:427:15)
    at Scope.checkBlockScopedCollisions (/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:398:27)
    at Scope.registerBinding (/node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:592:16)
    at Scope.registerDeclaration (node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:496:14)
    at Object.BlockScoped (node_modules/babel-core/node_modules/babel-traverse/lib/scope/index.js:244:28)
    at Object.newFn (node_modules/babel-core/node_modules/babel-traverse/lib/visitors.js:318:17)
    at NodePath._call (node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:76:18)
    at NodePath.call (/node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:44:14)
    at NodePath.visit (/node_modules/babel-core/node_modules/babel-traverse/lib/path/context.js:105:12)

Info : When I was working react-native 48.4 If I enable Hot module reloading(hmr) I used to get this error .After updating to 51.0 I could not able to development server because of bundling error


Solution

  • Probably issue is with transform-react-remove-prop-types babel plugin.

    Try removing this plugin from .babelrc , it will solves the problem.