How to call Screen / Component class method from react-navigation Header

后端 未结 5 2059
死守一世寂寞
死守一世寂寞 2021-02-09 00:27

I need to call SearchScreen class method from a React Navigation Header.

The Navigator look like this:

  Search: {
    screen: SearchScreen,
    path: \'         


        
5条回答
  •  深忆病人
    2021-02-09 00:51

    I've resolved the issueI've resolved the issue be the following way:

    static navigationOptions = ({ navigation }) => {
        return {
            headerRight: () => (
    
                
                    Sync
                
            ),
        };
    };
    
    componentDidMount() {
        this.props.navigation.setParams({ onPressSyncButton: this._onPressSyncButton });
    }
    
    _onPressSyncButton = () => {
         console.log("function called");
    }
    

提交回复
热议问题