React-Redux-Saga history.push正在更新url,但未加载组件

时间:2020-09-18 18:58:08

标签: reactjs react-router redux-saga

更改密码后,我尝试从saga重定向,history.push()只是在更新URL而不加载组件

Hisotry.js

import { createBrowserHistory as history } from "history";
export default history({
  bforceRefresh: true,
});

App.js

import React from "react";
import { BrowserRouter } from "react-router-dom";
import history from "../../helpers/history";
import Navigation from "../Navigation";
import AppAuthRouter from "../Navigation/routes";
const App = () => (
  <BrowserRouter history={history}>
    <Navigation app_auth_router={AppAuthRouter} />
  </BrowserRouter>
);
export default App;

AppAuthRouter.js

import * as ROUTES from "../../constants/routes";
import ProtectedRoute from "./protectedroute";
const AppAuthRouter = () => (
  <Switch>
    <ProtectedRoute path="/admin" component={AdminPage} />
    <ProtectedRoute
      path="/updatepwd"
      component={PasswordChangePage}
    />
    <ProtectedRoute path="/welcome" component={WelcomePage} />
    <Route path={"/signup} component={SignUpPage} />
    <Route path={"/signin} component={SignInPage} />
    <Redirect path="*" to={{ pathname:"/signin"}} />
  </Switch>
);
export default AppAuthRouter;

Saga.js

import history from "../helpers/history";
function* passwordChangeSaga({ creds }) {
  try {
    yield put(alertSuccess("Password has been changed successfully"));
    history.push("/welcome");
  } catch (gerror) {
    const error = googleError2Error(gerror);
  }
}

0 个答案:

没有答案
相关问题