答案 0 :(得分:0)
https://snack.expo.io/r1tmEEYs4实时基础示例
您返回时有一个小错误,您必须像这样更改标头代码
import React, { Component } from 'react';
import { Text } from 'react-native';
class Header extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
return (
<Text>
Header Text
</Text>
);
}
}
export default Header;
您必须这样称呼
import * as React from 'react';
import { Text, View, StyleSheet } from 'react-native';
import Header from './components/Header';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Header/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
backgroundColor: '#ecf0f1',
padding: 8,
},
});
首先打开终端并运行
npm start -- --reset-cache
然后
react-native run-ios