1
votes

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

2
have a look to my answer and mark it as accepted if that helps. - Piyush Zalani

2 Answers

0
votes

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} />
-1
votes

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