我正在使用CRNA v0.44。我正在進行兩個屏幕註冊。我在第一個屏幕上,現在我想要使用react-navigation進入第二個屏幕。未定義不是對象(評估'this.props.navigation.navigate')(常見問題)(CRNA)
但得到錯誤:
undefined is not an object (evaluating 'this.props.navigation.navigate')
我已經探索互聯網和發現需要道具傳遞給按鈕,但沒能搞清楚如何?
SignupForm.js:
import {
StackNavigator,
} from 'react-navigation'
import SignupForm2 from './SignupForm2'
const App = StackNavigator({
SignupForm2: { screen: SignupForm2 },
});
export default class SignupForm extends Component {
render() {
const { navigate } = this.props.navigation
return (
<Button
title="Go to Jane's profile"
onPress={() =>
navigate('SignupForm2', { name: 'SignupForm2' })
}
/>
)
}
}
您是否將navigation prop傳遞到組件? –