我是新的反应,导航和我遵循site上的步骤,但我得到一个错误,说'路线'聊天'应该宣布一个屏幕...下面是我的代码供参考。反应 - 导航:路线应宣布一个屏幕...错误
import React from 'react';
import {
AppRegistry,
Text,
View,
Button,
} from 'react-native';
import { StackNavigator } from 'react-navigation';
class HomeScreen extends React.Component {
static navigationOptions = {
title: 'Welcome',
};
render() {
const { navigate } = this.props.navigation;
return (
<View>
<Text>Hello, Chat App!</Text>
<Button
onPress={() => navigate('Chat')}
title="Chat with Lucy"
/>
</View>
);
}
}
AppRegistry.registerComponent('navigationApp',() => navigationApp);
这是我认为的错误发生
const navigationApp = StackNavigator({
Home: { screen: HomeScreen },
Chat: { screen: ChatScreen },
});
class ChatScreen extends React.Component {
static navigationOptions = {
title: 'Chat with Lucy',
};
render() {
return (
<View>
<Text>Chat with Lucy</Text>
</View>
);
}
}
您可以测试在navigationApp上方声明ChatScreen .. –
@NeelGala谢谢,实际上工作。 – NSCoder