The prop `history` is marked as required in `Router`, but its value is `undefined`. in Router

前端 未结 7 946
甜味超标
甜味超标 2021-01-30 01:50

I am new to ReactJs. This is my code:

var React = require(\'react\');
var ReactDOM = require(\'react-dom\');
var {Route, Router, IndexRoute, hashHistory} = requ         


        
7条回答
  •  一整个雨季
    2021-01-30 02:50

    I got the same problem in ES6, but when I switched to use 'react-router-dom' library, the problem was solved. For all fans of ES6, here we go:

    npm install --save react-router-dom

    In index.js:

    import {HashRouter, Route} from 'react-router-dom';
    import App from './App';
    
    ReactDOM.render(
        
            
        
      ,
      document.getElementById('root')
    );
    

提交回复
热议问题