我知道这个问题已被问过很多次了,但我读过的解决方案并没有在我的案例中解决。我的代码非常简单明了:
// 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);
我正在使用expo开发ios应用程序。它一直显示元素类型无效:期望一个字符串(对于内置组件)或类/函数但得到:对象。您可能忘记从其定义的文件中导出组件。
检查'AwakeInDevApp'的渲染方法
任何见解都将受到赞赏:)
答案 0 :(得分:0)
React native有时可能会挑剔地将视野包裹在视图中并赋予它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);