我正在使用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传递到组件? –