-
-
Notifications
You must be signed in to change notification settings - Fork 27k
React Router Not Working #1807
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
Which version of react-router are you using? |
My package.json says 3.0.2 |
You need to go to localhost:8080/#/material to access your material component because you are using hashHistory. |
Thank you for the help. Is there a way to eliminate having to use the hashHistory or history altogether? I believe when I was not feeding the history prop, no pages would load and I received an error in the console saying "Cannot read property 'getCurrentLocation' of undefined". |
If you want to use the browser history, you should pass the import { browserHistory } from 'react-router';
ReactDOM.render(
<Router history={browserHistory}> I hope this helps! |
Thank you everyone for the help! |
Be careful if you decide to upgrade to 4.0. I was having similar issue as you but with hashHistory and BrowserHistory being undefined, it is because 4.0 injects the history into the props you pass down to your routes. Lock down your ver if you don't want things to break on a deploy to prod :) |
@danieldram may I ask what do you mean by "lock down your ver" plz? |
@alisonzthu he's probably referring to not using To truly lock down your versions, you must use Yarn. |
@Timer, I see. Thanks for the explanation! |
I've found that using browserHistory prevents me from navigating directly to custom routes (going straight to example.com/mypath in-browser doesn't work). Is there an easy way around this shortcoming of browserHistory? |
That is a question better asked in the react router community. That said, make sure your production configuration serves index.html for all routes not explicitly matched. |
I am having trouble using React Router to create another static page within my app.
Here is what my render method looks like:
When I try to visit localhost:8080/material, the url redirects to localhost:8080/material#/ and I the page just loads Home instead of Material. There is no way for me to access my Material Component.
The same error occurs when I reconfigure the render method to look like this:
What do I have to do to get access to different routes?
edit: forgot question mark
The text was updated successfully, but these errors were encountered: