新來反應原生,嘗試呈現主頁與導航上的按鈕去用戶頁面。反應原生this.refs.nav未定義
var TourChampIOs = React.createClass({
getInitialState() {
....
},
componentWillMount() {
....
},
_handleUserDataPress: function() {
// Get by ref not prop
this.refs.nav.push({
component: UserPage,
title: 'User Page'
});
},
render: function() {
return <NavigatorIOS
style={styles.container}
initialRoute={{
title: 'Tour Champ',
component: ThemeList,
rightButtonTitle: tc.user.displayName.split(' ')[0],
onRightButtonPress: this._handleUserDataPress
}}/>;
}
我得到的錯誤是 Error: Cannot read property 'push' of undefined
不關注你。你能粘貼示例代碼嗎? – WebQube
你真的不應該在評論中發佈代碼,爲什麼不編輯你的答案呢? – luschn
@luschn是對的 – WebQube