简体   繁体   English

反应路由器页面无法刷新

[英]react router page not able to refresh

I want to try nested routing but it is not working 我想尝试嵌套路由,但无法正常工作

Codesandbox Link Codesandbox链接

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 场景:当我第一次在/ category / bags上路由时,它正确呈现,但是当我在此页面上刷新时,它给了我错误页面未找到

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 我尝试使用this.props.match.url和this.props.match.path,但是在这里出现错误,例如没有prop match.url

I have tried following links 我尝试了以下链接

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

How to include the Match object into a ReactJs component class? 如何将Match对象包含到ReactJs组件类中?

Nested routes with react router v4 使用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' 尝试使用ConnectedRouter from 'react-router-redux'BrowserRouter from 'react-router-dom'而不是BrowserRouter from 'react-router-dom'BrowserRouter from 'react-router-dom'

This article i hope can help you : 我希望这篇文章可以对您有所帮助:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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