我知道这个问题已经被问了很多次了,但我读到的解决方案在我的情况下不起作用。我的代码非常简单明了:
// 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);
我正在使用博览会来开发ios应用程序。它一直显示元素类型无效:预期字符串(用于内置组件)或类/函数,但得到:对象。您可能忘记从定义组件的文件中导出组件。
检查"AwakeInDevApp"的渲染方法
任何见解将不胜感激:)
React native 有时会挑剔地将字段包装在视图中,并赋予其 flex 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);