我在代码存在的反应原生代码中使用了以下代码:
header.js文件代码==
import React from 'react';
import { Text, View } from 'react-native';
const Header = () => {
const { textStyle, viewStyle } = styles;
return (
<View style={viewStyle}>
<Text style={textStyle}>Photography</Text>
</View>
);
};
const styles = {
viewStyle: {
backgroudColor: '#F8F8F8',
justifyContent: 'center',
alignItems: 'center',
height: 60,
paddingTop: 14
},
textStyle: {
fontSize: 20
}
};
export default Header;
app.js文件代码==
import React from 'react';
import { AppRegistry, Text } from 'react-native';
const App = () => ( <Text>Some Text</Text> );
AppRegistry.registerComponent('albums', () => App);
我在模拟器enter image description here
中收到以下错误如何解决此错误请告诉我如何删除该错误请任何人都可以帮助
答案 0 :(得分:0)
通常,您将拥有仅包含以下内容的index.js文件:
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('albums', () => App);
...然后在App.js
import React, { Component } from 'react';
...
import Header from './header';
export default class App extends Component<{}> {
...
render() {
return(
<View style={styles.container}>
<Header />
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
...
}