Issue
I want to add react-route to my app, i have the code below:
import React from 'react'; import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';
import App from './App.js';
ReactDOM.render(
<Router history={browserHistory}>
<Route exact path="/" component={App} />
</Router>,
document.getElementById('root')
);
app:
import React from 'react';
class App extends React.Component {
render() {
return (
<div className="container">
Hello
</div>
);
}
}
export default App;
I have a spring boot server which listens on 8080, in browser i get error when checking localhost:8080 (debug mozilla):
ReferenceError: Route is not defined
I have "react-router": "^4.1.1".
EDIT: imported route but i get now:
TypeError: i.props.history is undefined
UPDATE: Installed react-router 3.0.2 and worked.
Solution
Just import Route from react-router
import { browserHistory, Router, Route } from 'react-router';
Answered By - Simonov Dmitry
Answer Checked By - David Goodson (JavaFixing Volunteer)