React Router Not Working
See original GitHub issueI am having trouble using React Router to create another static page within my app.
Here is what my render method looks like:
ReactDOM.render(
<Router history={hashHistory}>
<Route path="/" component={Home}>
<Route path="material" component={Material}/>
</Route>
</Router>,
document.getElementById('root')
);
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:
ReactDOM.render(
<Router history={hashHistory}>
<Route path="/" component={Home}/>
<Route path="/material" component={Material}/>
</Router>,
document.getElementById('root')
);
What do I have to do to get access to different routes? edit: forgot question mark
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
React route is not working | React Router - Stack Overflow
If the issue is that you've installed react-router-dom version 6 and you are working from an outdated tutorial, then replace the Switch ......
Read more >Routes not working in react router - Questions - OneCompiler
The problem is with the Nav Route, It is the base route to all routes. So, you need to tell react router that...
Read more >Why is my react Router not working - The freeCodeCamp Forum
im gonna try adding some GET requests for those url's in the server but I know there must be a nicer way. By...
Read more >React Router Frequently Faced Problems | by Shoaib Bhimani
If you have declared component and it is not rendering It could be below three Issues. First, if you are using any state...
Read more >React router page links not working in production : r/reactjs
You need to get your web host to serve the react bundle for all routes. Normally, it'll only serve the index.html for the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you everyone for the help!
If you want to use the browser history, you should pass the
browserHistory
instead.I hope this helps!