FlatList onClick navigate to next screen

前端 未结 1 1417
悲哀的现实
悲哀的现实 2021-02-14 18:15

How do I make a Flatlist navigate to the next screen when a row is clicked inside the Flatlist in react-native?

Edited: I posted all the codes inside my

1条回答
  •  轮回少年
    2021-02-14 18:33

    i have simple example for that :

    //Tasks Component
    const Tasks = (props) => {
         const { navigate } = props.navigation;
         //function to go to next screen
         goToNextScreen = () => {
             return navigate('Detail');
         }
         return (
          
             {
                  return(
                     this.goToNextScreen()}>
                         {item.key}
                    
                  )
                }
              }
            />
          
        );
    }
    
    //example for detail screen
    const Detail = (props) => {
        const { navigate } = props.navigation;
        return(
            Detail Screen
        );
    }
    
    //initial screen
    const App = StackNavigator({
      Tasks: {screen: Tasks},
      Detail: {screen: Detail},
    })
    

    maybe can help you, thanks :)

    0 讨论(0)
提交回复
热议问题