页面返回(自定义返回页面)


import React from 'react';
import { StyleSheet, View, TouchableOpacity, Image, Platform, BackHandler} from 'react-native';
import { connect } from 'react-redux';

class Select extends React.Component {

    static navigationOptions = ({navigation, screenProps}) => ({
        headerTitle: '头部信息',
        headerLeft:(
            navigation.state.params.navigatePress()} style={{padding:10}} >
               
            
        )
    });

    constructor(props) {
        super(props);
        this.state={
          
        }
    }

    _onBackAndroid=()=>{
        this.props.navigation.navigate('要返回的页面路由')
    }
    
    componentWillMount() {
       this.props.navigation.setParams({ navigatePress:this._onBackAndroid })
       if (Platform.OS === 'android') {
           BackHandler.addEventListener("hardwareBackPress", this._onBackAndroid);
       }
    }

    componentWillUnmount() {
        if (Platform.OS === 'android') {
            BackHandler.removeEventListener("hardwareBackPress", this._onBackAndroid);
        }
    }

    
    render() {
        return (
            
               
            
        );
    }
}

export default connect()(Select);

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#FFFFFF',
    },
    
});

你可能感兴趣的:(页面返回(自定义返回页面))