How to Pass Parameters to screen in StackNavigator?

后端 未结 6 1355
抹茶落季
抹茶落季 2020-12-13 05:46

My React Native code:

import React, { Component } from \'react\';
import { AppRegistry, ActivityIndicator, StyleSheet, ListView, 
  Text, Button, TouchableH         


        
6条回答
  •  醉梦人生
    2020-12-13 06:50

    for me, soved it by useNavigation() and useRoute():

    For functional component:

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

    For class component:

    class MyText extends React.Component {
      render() {
        // Get it from props
        const { route } = this.props;
      }
    }
    
    // Wrap and export
    export default function(props) {
      const route = useRoute();
    
      return ;
    }
    

提交回复
热议问题