我是新的反應,導航和我遵循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