-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Uncaught TypeError: Cannot read property 'push' of undefined #3225
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
Comments
Thanks for your question! We want to make sure that the GitHub issue tracker remains the best place to track bug reports and feature requests that affect the development of React Router, and per the issue template, we are not handling support requests here. If you have a question or otherwise need help, please post on Stack Overflow with the #react-router tag at https://stackoverflow.com/questions/ask?tags=react-router, or drop in on the #react-router room on Reactiflux at https://discord.gg/0ZcbPKXt5bYaNQ46. |
@taion This is a bug report. |
You are using the library incorrectly. Please follow the tutorial, consult the documentation, or reach out on a support channel. |
+1 |
+1 same problem |
@taion is correct. The problem is this: https://gist.github.com/bodokaiser/8482e0932fe242967c8f#file-app-index-js-L45:L47. The Link components are used outside the context of the router and will not be able to access your browserHistory object. The Link component needs to be used in a children component of the Router. You should be able to use Link from your Home, About, Contacts components since they are children components of the Router. If you need to handle route changes outside the scope of the router you can pass the browserHistory and call browserHistory.push(path). This is best described here: https://github.com/reactjs/react-router-tutorial/tree/master/lessons/12-navigating |
Yes this is the solution - however it is easy to forget or to not see the problem so it is good that this is now some sort of resource to this problem. |
Version
2.0.1
Test Case
https://gist.github.com/bodokaiser/8482e0932fe242967c8f
Steps to reproduce
mkdir app && mv app-index.js app/index.js
npm install && npm start
Expected Behavior
Router should dispatch route when clicking on link.
Actual Behavior
Nothing happens.
Here seems to be the problem
Link.js:124
:The text was updated successfully, but these errors were encountered: