Peter G.
Peter G.

Reputation: 8034

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

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"]
}

Upvotes: 0

Views: 360

Answers (1)

Daniel Schmidt
Daniel Schmidt

Reputation: 11921

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

import React from 'react';

at the top of your file.

Upvotes: 1

Related Questions