react native component has no access to props - TypeError: Cannot read property ‘navigation’ of undefined
react native component has no access to props - TypeError: Cannot read property ‘navigation’ of undefined
enter image description here
TypeError: 无法读取 属性 未定义的“导航”?
看起来我的组件无法访问 this.props.navigation.( react-navigation)
基本上我每次调用都会收到此错误: const { navigate } = this.props.navigation.
知道如何让组件访问 this.props.navigation 吗?
ES6 类 不要自动绑定 this
。有一些解决方案,例如在构造函数中绑定或将其更改为箭头函数:
renderRow = ({ item }) => {
// rest of code
}
enter image description here
TypeError: 无法读取 属性 未定义的“导航”? 看起来我的组件无法访问 this.props.navigation.( react-navigation) 基本上我每次调用都会收到此错误: const { navigate } = this.props.navigation.
知道如何让组件访问 this.props.navigation 吗?
ES6 类 不要自动绑定 this
。有一些解决方案,例如在构造函数中绑定或将其更改为箭头函数:
renderRow = ({ item }) => {
// rest of code
}