我是React-native的新手,我正在尝试为我的应用创建场景。我遇到两件事情有困难:首先,我无法理解为什么带标题的导航栏没有显示。我正在使用React Navigation。其次,我不知道我开始开发应用程序的方式是否正确。
Index.js
import { AppRegistry } from 'react-native';
import App from './App';
AppRegistry.registerComponent('Hola', () => App);
App.js
import React, { Component } from 'react';
import {
View,
} from 'react-native';
import Hola from './src/ConversationListScreen';
import styles from './src/styles';
export default class App extends Component<{}> {
render() {
return (
<View>
<Hola/>
</View>
);
}
}
的src / ConversationListScreen.js
import React, { Component } from 'react';
import { StackNavigator } from 'react-navigation';
import {
AppRegistry,
Text,
View,
} from 'react-native';
export default class ConversationListScreen extends Component
{
static navigationOptions = {
title: 'Hola',
};
render() {
return <Text>Hello, Navigation</Text>;
}
}
export const Hola = StackNavigator({
ConversationList: { screen: ConversationListScreen },
});
AppRegistry.registerComponent('ConversationListScreen', () => Hola);