react-navigation - navigating from child component

后端 未结 4 733
面向向阳花
面向向阳花 2020-12-16 01:12

I have a leaderboard which calls a component and passes it data to it like so:

   _renderItem =({item}) => (
    

        
4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 01:46

    The useNavigation hook was introduced in v5:

    import * as React from 'react';
    import { Button } from 'react-native';
    import { useNavigation } from '@react-navigation/native';
    
    export function ChildComponent() => {
      const navigation = useNavigation();
    
      return (
        

    Docs: https://reactnavigation.org/docs/use-navigation

提交回复
热议问题