简体   繁体   中英

Error while evaluating JSX element in React Native

When running my app I get into an error while the babel compiler is processing the JSX. It could be due to misconfiguration in the .babelrc . Here is the error:

undefined is not an object (evaluating '_react.React.createElement')

Screenshot

  • Adding transform-react-jsx plugin for babel doesn't solve the problem

index.js:

renderLoadingView() {
  return (
    <View style={styles.container}>  // Failing on index.js:217
      <Text>
        Loading the app...
      </Text>
    </View>
  );
}

.babelrc:

{
  "presets": ["react-native-stage-0"]
}

You have to import React if you use JSX, so you need to write

import React from 'react';

at the top of your file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM