Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.context.history is undefined #6

Open
pokatomnik opened this issue Apr 11, 2017 · 1 comment
Open

this.context.history is undefined #6

pokatomnik opened this issue Apr 11, 2017 · 1 comment

Comments

@pokatomnik
Copy link

pokatomnik commented Apr 11, 2017

index.js:

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.

@ccapndave
Copy link
Owner

ccapndave commented Apr 18, 2017

I'm afraid that I am currently not using React nor this component so I can't make any fixes. I'd be happy to receive PRs if anyone wants to fix this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants