反应导航-导入文件导航页面

问题描述 投票:-1回答:1

此文件导入

class Footer extends Component {
  _notifications = () => {
    const { navigate } = this.props.navigation;
    navigate('Ntf', {});
  }

  render() {
    return (<TouchableHighlight onPress={() => this._notifications()} ></TouchableHighlight>);
  }
}

此文件主目录(React-Navigation-NavigationDrawerStructure)。

import { Footer } from './Footer';
export default class HomePage extends Component {
render() {
    return (<View><Footer/></View>);
}

错误后单击_notifications按钮:undefined是一个对象c.props.navigation.navigate请帮助我

react-native react-navigation expo react-navigation-drawer
1个回答
0
投票

仅在路线中定义的组件有权访问导航道具,而不能访问这些组件的子项!。

解决方案:-

© www.soinside.com 2019 - 2024. All rights reserved.