坑之 react-navigation

  1. yarn add react-navigation

  2. import {StackNavigator } from 'react-navigation';

class MainScreen extends React.Component {
  constructor(props) {
    super(props)
  }
  static navigationOptions = {
    title: 'Welcome',
  };
  render() {
    const { navigate } = this.props.navigation;
    return (
      
  1. 引导页(路由重置)
    import { NavigationActions } from 'react-navigation'
    
    componentDidMount() {
        const resetAction = NavigationActions.reset({
            index: 0,
            actions: [
              NavigationActions.navigate({ routeName: 'AppPage'})
            ]
        })
    
      this.timer = setTimeout(()=> {
          this.props.navigation.dispatch(resetAction)
     }, 2000)
    }
    
    componentWillMount() {
        this.timer && clearTimeout(this.timer)
    }
    

你可能感兴趣的:(坑之 react-navigation)