Reactjs 重定向不';t渲染组件

Reactjs 重定向不';t渲染组件,reactjs,react-router,react-router-v4,Reactjs,React Router,React Router V4,这是问题的后续内容: 以下代码正确地执行重定向,但实际上并不呈现与重定向url相关的组件。 下面是我的代码,是对上一个问题中给出的代码的一个小修改 // Authentication "before" filter function requireAuth(){ if(isLoggedIn()) return <Home /> else return <Redirect to="/front"/> } // Render the app ren

这是问题的后续内容:

以下代码正确地执行重定向,但实际上并不呈现与重定向url相关的组件。
下面是我的代码,是对上一个问题中给出的代码的一个小修改

// Authentication "before" filter
function requireAuth(){
  if(isLoggedIn())
    return <Home />
  else
    return <Redirect to="/front"/>
}

// Render the app
render(
  <Provider store={store}>
      <Router history={history}>
        <App>
          <Switch>
            <Route path="/front" component={Front} />
            <Route path="/home" render={requireAuth} />
            <Route exact path="/" render={requireAuth} />
            <Route path="*" component={NoMatch} />
          </Switch>
        </App>
      </Router>
  </Provider>,
  document.getElementById("lf-app")
)

您的
历史记录设置如何?@请参阅更新。History v^4.6.0重定向后,是否可以将组件中的
位置
道具的值与History.location值进行比较?如果它们不同步,我建议暂时删除商店同步部分,然后再试一次。我有这样的代码用于路由器-v4 alpha,但在beta版和stable版中,它也不再适用于我。您是在您的应用程序中使用
connect()
,还是其他什么?
... 
import {createBrowserHistory}           from "history";

// Init sagaMiddleware
const sagaMiddleware = createSagaMiddleware();
const store = createStore(
    appReducers,
    applyMiddleware(sagaMiddleware)
);

const history = syncHistoryWithStore(createBrowserHistory(), store);