简体   繁体   中英

react router page not able to refresh

I want to try nested routing but it is not working

Codesandbox Link

Scenario: when I route for first time on /category/bags it is rendering correctly but when I refresh on this page it is giving me error page Not found

I tried with this.props.match.url and this.props.match.path but here I am getting error like there is no prop match.url

I have tried following links

https://reacttraining.com/react-router/web/guides/quick-start

How to include the Match object into a ReactJs component class?

Nested routes with react router v4

I have seen your code and found that you are using exact in parent routing:

<Route exact path="/category" component={Category} />

If you remove the exact from parent routing then it will work fine:

<Route path="/category" component={Category} />

Try to use ConnectedRouter from 'react-router-redux' instead of BrowserRouter from 'react-router-dom'

This article i hope can help you :

https://medium.com/@Dragonza/react-router-problem-with-gh-pages-c93a5e243819

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM