【发布时间】:2017-06-15 17:17:28
【问题描述】:
我正在使用 CRNA v0.44 。我正在做一个两屏注册。我在第一个屏幕上,现在我想使用 react-navigation 转到第二个屏幕。
但出现错误:
undefined 不是对象(评估 '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' })
}
/>
)
}
}
【问题讨论】:
-
您是否将导航道具传递给任何地方的组件?
标签: javascript react-native react-native-android react-navigation create-react-native-app