我是React本地新手。我正在嘗試將react navigation添加到我的登錄頁面,用戶可以點擊一個按鈕並導航到註冊頁面,但我收到錯誤Cannot read property 'navigate' of Undefined
。我已經通過互聯網搜索解決方案,但沒有運氣。這並不能幫助我 - React Navigation - cannot read property 'navigate' of undefined和其他人一樣。無法讀取反應導航中未定義的屬性「導航」
這裏是我的代碼
index.ios.js
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import {StackNavigator} from 'react-navigation';
import Login from './src/screens/Login';
import Signup from './src/screens/Signup';
export default class tapak extends Component {
constructor(props) {
super(props);
this.buttonPress = this.buttonPress.bind(this);
}
render() {
return (
<View style={styles.container}>
<Text style={{color: 'blue'}} onPress={this.buttonPress}>sign up</Text>
</View>
);
}
buttonPress() {
console.log('called');
this.props.navigation.navigate('Signup');
}
}
const Stacks = StackNavigator({
Login: {
screen: Login
},
Signup:{
screen: Signup
}
});
你在哪裏使用「tapak」?它看起來不像你的堆棧 – QoP
我沒有在任何地方使用它。這是我的index.ios.js文件 – digit