React Router Redux - 使用 Link 或后退按钮时重复渲染

React Router Redux - Duplicate Renders when using Link or Back Button

当我单击 Link 或使用后退按钮时,我看到了重复的渲染。我可以转到任何页面并进行真正的浏览器刷新,一切都会正常进行。我的记录器显示 @@router/LOCATION_CHANGE 两次,这导致围绕事物的重复实例出现大量警告和异常。这似乎不是 hashHistory 与 browserHistory 的问题。正如人们在 github 问题上指出的那样。我在 "react-router-redux":“4.0.7”。将 adjustUrlOnReplay 设置为 false 似乎没有任何作用。一如既往,非常感谢任何帮助!下面是我的 configureStore 和 Routes js 文件。谁能帮我找到问题所在?谢谢!菲利普

configureStore.js

import { createStore, applyMiddleware, combineReducers, compose } from 'redux'
import thunk from 'redux-thunk'
import logger from 'redux-logger'
import rootReducer from '../reducers'
import createSagaMiddleware from 'redux-saga'
import rootSaga from '../sagas/sagas'
import promiseMiddleware from 'redux-promise-middleware'
import { syncHistoryWithStore} from 'react-router-redux'
import { browserHistory } from 'react-router'
import { apiMiddleware } from 'redux-api-middleware';

const sagaMiddleware = createSagaMiddleware()

const initialState = {
};

const enhancers = compose(
  window.devToolsExtension ? window.devToolsExtension() : f => f
);

const store = createStore(rootReducer, initialState, compose(
    applyMiddleware(apiMiddleware, thunk, logger(), sagaMiddleware),
    typeof window === 'object' && typeof window.devToolsExtension !== 'undefined' ? window.devToolsExtension() : f => f
  ));

export const history = syncHistoryWithStore(browserHistory, store);
sagaMiddleware.run(rootSaga);
export default store;

routes.js

import App from './App'
import '...a bunch of different components'
import { Provider } from 'react-redux'
import { Router, Route, IndexRoute, browserHistory } from 'react-router'
import store, { history } from './store/configureStore.js'

const router = (
  <Provider store={store}>
    <Router history={history}>
      <Route path="/" component={App}>
        <IndexRoute component={TeamsContainer}/>
        <Route path="teams" component={TeamsContainer} />
        <Route path="teams/:teamId" component={TeamContainer} />
        <Route path="teams/:teamId/add_member" component={AddMemberContainer} />
        <Route path="teams/:teamId/team_members/:teamMemberId" component={TeamMemberContainer} />
      </Route>
    </Router>
  </Provider>
)

if ( $('#app').length ) {
  ReactDOM.render(router, document.getElementById('app'));
}

https://github.com/ReactTraining/history/issues/427 更新到 react-router v4 解决这个问题。