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

Fixed JS console error with react-router history #246

Merged
merged 1 commit into from
May 2, 2016

Conversation

alicewriteswrongs
Copy link
Contributor

What are the relevant tickets?

none

What's this PR do?

React router throws up a console warning if you grab history out of
this.props instead of importing the history provider (e.g.
browserHistory or hashHistory) and calling .push on that.

This just makes that change, so the warning doesn't show up!

Where should the reviewer start?

static/js/containers/App.js and static/js/containers/TermsOfServicePage.js

How should this be manually tested?

  • update your profile so that agreed_to_terms_of_service == False
  • visit /dashboard
  • click 'agree'
  • confirm no JS console warning

Any background context you want to provide?

Screenshots (if appropriate)

original warning (can repro by following the 'manual testing' steps on master):

react-router-error

@bdero bdero temporarily deployed to micromasters-ci-pr-246 April 29, 2016 19:14 Inactive
@noisecapella
Copy link
Contributor

Unfortunately the tests rely on being able to provide a history object that isn't a browser history. Did you investigate the context.router suggestion in the error?

@alicewriteswrongs
Copy link
Contributor Author

I did not, I'll take a look

@alicewriteswrongs
Copy link
Contributor Author

@noisecapella yeah, I have no idea how to get around that, haha

we can just delete this if we're fine with living with the warning

@noisecapella
Copy link
Contributor

It would be nice to fix this eventually but it's not blocking anything right now

@alicewriteswrongs
Copy link
Contributor Author

@noisecapella I just took another stab at this, was following along with the docs here: https://github.com/reactjs/react-router/blob/master/upgrade-guides/v2.0.0.md#navigating-inside-deeply-nested-components

seems to be working ok! tests are passing too.

@noisecapella
Copy link
Contributor

That's great! 👍

React router throws up a console warning if you grab `history` out of
`this.props`. Following the docs here:

https://github.com/reactjs/react-router/blob/master/upgrade-guides/v2.0.0.md

we're now adding a `router` object in `this.context` on the components
where we need to be pushing something onto the history.
@bdero bdero requested a deployment to micromasters-ci-pr-246 May 2, 2016 15:29 Pending
@alicewriteswrongs alicewriteswrongs merged commit 1819255 into master May 2, 2016
@bdero bdero temporarily deployed to micromasters-ci May 2, 2016 15:29 Inactive
@alicewriteswrongs alicewriteswrongs deleted the ap/fix-js-error branch May 2, 2016 15:30
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

Successfully merging this pull request may close these issues.

None yet

3 participants