React native: failed to load bundle unexpected super class

Viewed 124

Whenever I run the IOS simulator it keeps giving me this error! why is that?

error: bundling failed: SyntaxError: .../node_modules/react-native/Libraries/Blob/FileReader.js: Unexpected super class type: CallExpression
  35 | const DONE = 2;
  36 | 
> 37 | class FileReader extends EventTarget(...READER_EVENTS) {
     |                          ^
  38 |   static EMPTY = EMPTY;
  39 |   static LOADING = LOADING;
  40 |   static DONE = DONE;
    at File.buildCodeFrameError
2 Answers

Faced this issue before, my react-native and react-native-cli were outdated, install react-native-git-upgrade and upgrade you project and it should work.

Also run the following command:

watchman watch-del-all &&
rm -rf $TMPDIR/react-native-packager-cache-* &&
rm -rf $TMPDIR/metro-bundler-cache-* && 
rm -rf node_modules/ && 
yarn cache clean &&
yarn install && 
yarn start -- --reset-cache

This can be caused by the react-flow-props-to-prop-types babel plugin.

Removing it fixed it for me.

  1. yarn remove babel-plugin-react-flow-props-to-prop-types --dev
  2. Remove react-flow-props-to-prop-types plugin from babel.config.js/.babelrc plugins
  3. You can also now yarn remove prop-types prop-types-extra if you are not using these anywhere else.
  4. react-native start and voila! :)

Thanks to @mattcosta7

Related