0

browser.js:警告:[react-router] Historymixin 已弃用,请使用context.router您自己的 contextTypes.

我的路线文件

const routes = (
  <Provider store={store}>
      <Router history={browserHistory}>
        <Route path="/" component={RootComponent}>
          <IndexRoute component={HomePage} />

          <Route path="profile" component={ProfilePage} >
            <IndexRoute component={ProfilePage} />
            <Route path="view/:profileId" component={ProfilePage} />
            <Route path="add" component={AddProfile} />
            <Route path="edit/:profileId" component={EditProfile} />
          </Route>

          <Route path="login" component={Login} />
          <Route path="onboard" component={Onboard} />
        </Route>
      </Router>
  </Provider>
);

export default routes;

和根

import React from 'react';
import { render } from 'react-dom';
import routes from './routes';
import "babel-polyfill";

const mountPoint = document.getElementById('application-root');

if (mountPoint) {
  render(routes, mountPoint);
} else {
  console.error('could not find application mount point');
}

反应路由器 v2.6.1

4

1 回答 1

1

该错误可能是由该行引起的。你从哪里导入'browserHistory'?

<Router history={browserHistory}>

在最新版本的 react-router 中,您需要从 react-router 包本身导入历史记录

import { browserHistory } from 'react-router'

<Router history={browserHistory} routes={routes} />

请参阅此链接以获取更多详细信息

于 2016-08-03T08:35:51.177 回答