英文:
why react router url changes but component does not load in my nested router app
问题
"react-router URL changes but the component do not load. my app content lots off the nested router.
see my layout
in this app my main two problem
- redirect
- component not load
see this gif video what is my problem
<blockquote class="imgur-embed-pub" lang="en" data-id="pGbivBq" data-context="false"><a href="//i.stack.imgur.com/TFsb1.jpg">why react router url changes but component does not load in my nested router app</a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
I share gif video because of my gif size big than 2mb.
in this gif video, you see when clicking on the logout button than not redirect.
second when clicking on the signup button my app not redirect.
plz tell me what is my problem"
英文:
react-router URL changes but the component do not load. my app content lots off the nested router.
see my layout
in this app my main two problem
- redirect
- component not load
see this gif video what is my problem
<blockquote class="imgur-embed-pub" lang="en" data-id="pGbivBq" data-context="false"><a href="//i.stack.imgur.com/TFsb1.jpg">why react router url changes but component does not load in my nested router app</a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
I share gif video because of my gif size big than 2mb.
in this gif video, you see when clicking on the logout button than not redirect.
second when clicking on the signup button my app not redirect.
plz tell me what is my problem
答案1
得分: 1
你只需将组件包装在withRouter内。
<Route exact path="/mypath" component={withRouter(MyComponent)} />
英文:
You just have to wrap the components inside withRouter.
<Route exact path="/mypath" component={withRouter(MyComponent)} />
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论