AH.
AH.

Reputation: 813

React.createElement: type is invalid on Expo

I'm just starting to learn React Native and I tried to do RN on Expo. Now I'm getting this error.

Warning: React.createElement: type is invalid -- expected a string (for 
built-in components) or a class/function (for composite components) 
but got: object. You likely forgot to export your component from the 
file it's defined in.

My code is

import React from 'react';
import {Text, AppRegistry} from 'react-native';

const App = () => (
    <Text>Some Text </Text>
    );


AppRegistry.registerComponent('helloworld', () => App );

I worte this cod on the App.js file

Upvotes: 1

Views: 660

Answers (1)

Jigar Shah
Jigar Shah

Reputation: 6223

You can do like this:

import React, { Component } from 'react';
import {Text, AppRegistry} from 'react-native';

export default class App extends Component {
  render() {
    return (
      <Text>Hello world!</Text>
    );
  }
}


AppRegistry.registerComponent('helloworld', () => App );

Upvotes: 1

Related Questions