如何在从 Redux 操作进行身份验证后重定向用户?

How to redirect user after authentication from Redux action?

我在 Action Redux 文件中使用 firebase 来验证我的用户。但是如何将他从登录页面重定向到另一个页面?

import firebase from '../app/firebase/firebase.js';

export const SIGN_IN = 'SIGN_IN'
export const GET_BOOKS = 'GET_BOOKS'

export const signInState = (email, password) => dispatch => {
          firebase.auth()
         .signInWithEmailAndPassword(email, password)
         .then(() => {
           dispatch({
          type: 'SIGN_IN',
          })
        push("/home") /// here i try to redirect user
        })
        .catch((error) => {
        console.log(error);
        alert(error);
     })
}

而且我的应用程序文件中也有 PrivateRoute。如何达到这个"path"?

      <PrivateRoute
            path="/home"
            signedInStatus={this.props.signedInStatus}
            component={Home} />}/>

我刚用过Connected-React-Router

解决我的问题:

export const signInState = (email, password) => dispatch => {
      firebase.auth()
     .signInWithEmailAndPassword(email, password)
     .then(() => {
       dispatch({
      type: 'SIGN_IN',
      })
    dispatch(push('/home')) /// <-----that was an answer
    })