Getting undefined is not an object evaluating _this.props.navigation

前端 未结 13 1724
说谎
说谎 2020-12-14 15:19

I\'m using DrawerNavigator and I have 3 pages: Router page, mainScreen and a photos page,
I maked a header navbar are

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 15:45

    If you want navigation in child component,then you have to get props in child component.

    Suppose you have 3 components - Comp_1,Comp_2,Comp_3 and you want to navigate from Comp_2 -> Comp_3. To do this follow these steps.

    1. Pass props in Comp_1 component.Like this

    2. Now in Comp_2, we can navigate from Comp_2 -> Comp_3 like this.

      this.props.navigation.navigate('Comp_3');

    For example -

提交回复
热议问题