Reputation: 29
I know this question has been asked for a number of times, but solutions I read don't work out in my case. My codes are super simple and straightforward:
// Import a library to help create a component
import React from 'react';
import { AppRegistry, Text } from 'react-native';
//Only access text and AppRegistry from React-native lib
//Create a component
const App = () => (
<Text>Some Text</Text>
);
//Render it to the device
AppRegistry.registerComponent('myapp2_albums', () => App);
I am using expo to develop ios app. It keeps showing Element type is invalid: expected a string (for built-in components) or a class/function but got: object. You likely forgot to export your component from the file it's defined in.
Check the render method of ‘AwakeInDevApp’
Any insight would be appreciated:)
Upvotes: 0
Views: 358
Reputation: 384
React native can sometimes be picky about wrapping your fields within a view and give it a flex of 1.
import React from 'react';
import { AppRegistry, Text } from 'react-native';
//Only access text and AppRegistry from React-native lib
//Create a component
export default const App = () => {
return (
<View style={{ flex: 1}}>
<Text>Some Text</Text>
</View>
);
};
//Render it to the device
AppRegistry.registerComponent('myapp2_albums', () => App);
Upvotes: 1