import 'babel-polyfill';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
import { Router, Route, IndexRoute } from 'react-router';
import { createHashHistory } from 'history';
const history = createHashHistory();
ReactDOM.render(
<Router history={ history }>
<Route path="/" component={App}>
</Route>
</Router>,
document.getElementById('root')
);
App.js:
import React, { Component } from 'react';
import { Link } from 'react-router-link';
import logo from './logo.svg';
import './App.css';
class App extends Component {
render() {
return (
<div className="App">
<Link historyType="replace" to="/someplace">Click to go to someplace</Link>
</div>
);
}
}
export default App;
When I click to this link an error appear in console:
index.js:111 Uncaught TypeError: Cannot read property 'replaceState' of undefined
Then I go deeper into sources:
this.context.history.replaceState(this.props.state, this.props.to, this.props.query);
This.context.history is undefined here.
index.js:
App.js:
When I click to this link an error appear in console: index.js:111 Uncaught TypeError: Cannot read property 'replaceState' of undefined Then I go deeper into sources: this.context.history.replaceState(this.props.state, this.props.to, this.props.query); This.context.history is undefined here.