2016-08-02 7 views
0

browser.js:警告:[反応-ルータ] Historyミックスインは、あなた自身の contextTypescontext.routerにアクセスしてください非推奨 です。反応ルータでこの警告が発生した原因は何ですか?

私のルートは、エラーが、このラインが原因である可能性があり

+0

ためthis linkを参照してください発する行にブレークポイントを置きますその警告が表示され、スタックトレースがこの項目がチェックされている場所までチェックされます。それから、正確に何が起こるのかが分かります。 – zerkms

答えて

1

リアクト・ルータをv2.6.1

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'); 
} 

を提出します。どこから 'browserHistory'をインポートしていますか?反応-ルータの最新版では

<Router history={browserHistory}> 

、あなたが反応し、ルータをパッケージ自体

import { browserHistory } from 'react-router' 

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

から歴史をインポートする必要があり、さらに詳細

関連する問題