如何使用React导航从Redux表单导航到另一个屏幕?

时间:2019-01-07 05:35:39

标签: react-native redux react-redux react-navigation

我基本上希望在props.handleSubmit函数中可以导航到另一个屏幕。

这是我的code

import React, { Component } from "react";
import { createStackNavigator, createAppContainer } from 'react-navigation';
import { Provider } from 'react-redux';

import Store from './Store/Store'
import ScreenSignUp from './Navigation/ScreenSignUp';
import ScreenSignIn from './Navigation/ScreenSignIn';
import ScreenHome from "./Navigation/ScreenHome";

class App extends Component {
  render() {
    return (
      <Provider store={Store}>
        <AppContainer />
      </Provider>
    );
  }
}
export default App;

const RootStack = createStackNavigator(
  {
    Home: ScreenHome,
    SignUp: ScreenSignUp,
    SignIn: ScreenSignIn,
  },
  {
    initialRouteName: 'SignIn',
    defaultNavigationOptions: {
      header: null,
    },
  },
);

const AppContainer = createAppContainer(RootStack);

1 个答案:

答案 0 :(得分:0)

您可以这样做

 export default reduxForm({ 
 form: 'SignInForm',
 onSubmitSuccess : (result, dispatch, props) => {
     props.navigation.navigate('Register');
  },   
  onSubmitFail : () => {
  Toast.show({
    text: "Enter Passport Number",
    duration: 2500,
    position: "top",
    textStyle: { textAlign: "center" }
  });   
  }
  validate,
  })(SignInForm);