我想在props
版本5的一个功能组件中使用{navigation}
和react-navigation
这是我的代码:
const Header =(props, {navigation})=>{
return()}
但是它不起作用,我无法激活抽屉。它返回以下错误:
undefined is not an object(evaluating 'navigation.openDrawer)
您需要查找解构:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
示例:
const Header = (props)=> {
const { navigation } = props;
// Now you can use `navigation`
// Instead of destructuring, you can also use `props.navigation`
}