search
HomeWeb Front-endJS TutorialWhy are nested subroutines not effective in React Router 4.3 and how to solve this problem?

Why are nested subroutines not effective in React Router 4.3 and how to solve this problem?

React Router 4.3 Detailed explanation of nested routing configuration and problem investigation

When building applications using React Router 4.3, the correct configuration of nested routing is crucial. This article will analyze a common nested routing failure problem and provide effective solutions.

Suppose you want to nest a subroutine /course/coursedetails /course/coursedetails/coursecatalog path, but you get a 404 error when accessing the subroutine. This is usually caused by the parent route having exact attribute configured.

Let's analyze a typical misconfiguration:

Example of Error Configuration:

Assume that the configuration of the parent route in app.js is as follows:

 // app.js
<route exact path="/course/coursedetails" component="{CourseDetails}"></route>

The subroutine configuration inside CourseDetails.js component is as follows:

 // CourseDetails.js
<route path="/course/coursedetails/coursecatalog" component="{CourseCatalog}"></route>

Since the parent route in app.js uses the exact attribute, React Router will accurately match the /course/coursedetails path. When accessing /course/coursedetails/coursecatalog , React Router does not continue to match the subroutine downwards due to the incomplete matching of the parent route, resulting in a 404 error.

Solution:

The solution is simple, just remove exact attribute in the parent route:

Example of correct configuration:

Modify the parent route configuration in app.js :

 // app.js
<route path="/course/coursedetails" component="{CourseDetails}"></route>

The subroutine configuration in CourseDetails.js remains unchanged:

 // CourseDetails.js
<route path="/course/coursedetails/coursecatalog" component="{CourseCatalog}"></route>

By removing the exact attribute, React Router will first match the parent route /course/coursedetails , and then continue to match its child route /course/coursedetails/coursecatalog , thereby rendering the sub-routing component correctly.

I hope the above analysis and solutions can help you solve the problem of nested routing failure in React Router 4.3. Make sure the path is case consistent and check if the component name matches the routing configuration.

The above is the detailed content of Why are nested subroutines not effective in React Router 4.3 and how to solve this problem?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
ai合并图层的快捷键是什么ai合并图层的快捷键是什么Jan 07, 2021 am 10:59 AM

ai合并图层的快捷键是“Ctrl+Shift+E”,它的作用是把目前所有处在显示状态的图层合并,在隐藏状态的图层则不作变动。也可以选中要合并的图层,在菜单栏中依次点击“窗口”-“路径查找器”,点击“合并”按钮。

ai橡皮擦擦不掉东西怎么办ai橡皮擦擦不掉东西怎么办Jan 13, 2021 am 10:23 AM

ai橡皮擦擦不掉东西是因为AI是矢量图软件,用橡皮擦不能擦位图的,其解决办法就是用蒙板工具以及钢笔勾好路径再建立蒙板即可实现擦掉东西。

谷歌超强AI超算碾压英伟达A100!TPU v4性能提升10倍,细节首次公开谷歌超强AI超算碾压英伟达A100!TPU v4性能提升10倍,细节首次公开Apr 07, 2023 pm 02:54 PM

虽然谷歌早在2020年,就在自家的数据中心上部署了当时最强的AI芯片——TPU v4。但直到今年的4月4日,谷歌才首次公布了这台AI超算的技术细节。论文地址:https://arxiv.org/abs/2304.01433相比于TPU v3,TPU v4的性能要高出2.1倍,而在整合4096个芯片之后,超算的性能更是提升了10倍。另外,谷歌还声称,自家芯片要比英伟达A100更快、更节能。与A100对打,速度快1.7倍论文中,谷歌表示,对于规模相当的系统,TPU v4可以提供比英伟达A100强1.

ai可以转成psd格式吗ai可以转成psd格式吗Feb 22, 2023 pm 05:56 PM

ai可以转成psd格式。转换方法:1、打开Adobe Illustrator软件,依次点击顶部菜单栏的“文件”-“打开”,选择所需的ai文件;2、点击右侧功能面板中的“图层”,点击三杠图标,在弹出的选项中选择“释放到图层(顺序)”;3、依次点击顶部菜单栏的“文件”-“导出”-“导出为”;4、在弹出的“导出”对话框中,将“保存类型”设置为“PSD格式”,点击“导出”即可;

ai顶部属性栏不见了怎么办ai顶部属性栏不见了怎么办Feb 22, 2023 pm 05:27 PM

ai顶部属性栏不见了的解决办法:1、开启Ai新建画布,进入绘图页面;2、在Ai顶部菜单栏中点击“窗口”;3、在系统弹出的窗口菜单页面中点击“控制”,然后开启“控制”窗口即可显示出属性栏。

GPT-4的研究路径没有前途?Yann LeCun给自回归判了死刑GPT-4的研究路径没有前途?Yann LeCun给自回归判了死刑Apr 04, 2023 am 11:55 AM

Yann LeCun 这个观点的确有些大胆。 「从现在起 5 年内,没有哪个头脑正常的人会使用自回归模型。」最近,图灵奖得主 Yann LeCun 给一场辩论做了个特别的开场。而他口中的自回归,正是当前爆红的 GPT 家族模型所依赖的学习范式。当然,被 Yann LeCun 指出问题的不只是自回归模型。在他看来,当前整个的机器学习领域都面临巨大挑战。这场辩论的主题为「Do large language models need sensory grounding for meaning and u

AI抢饭碗成真!近500家美国企业用ChatGPT取代员工,有公司省下超10万美元AI抢饭碗成真!近500家美国企业用ChatGPT取代员工,有公司省下超10万美元Apr 07, 2023 pm 02:57 PM

自从ChatGPT掀起浪潮,不少人都在担心AI快要抢人类饭碗了。然鹅,现实可能更残酷QAQ......据就业服务平台Resume Builder调查统计,在1000多家受访美国企业中,用ChatGPT取代部分员工的,比例已达到惊人的48%。在这些企业中,有49%已经启用ChatGPT,还有30%正在赶来的路上。就连央视财经也为此专门发过一个报道:相关话题还曾一度冲上了知乎热榜,众网友表示,不得不承认,现在ChatGPT等AIGC工具已势不可挡——浪潮既来,不进则退。有程序员还指出:用过Copil

ai移动不了东西了怎么办ai移动不了东西了怎么办Mar 07, 2023 am 10:03 AM

ai移动不了东西的解决办法:1、打开ai软件,打开空白文档;2、选择矩形工具,在文档中绘制矩形;3、点击选择工具,移动文档中的矩形;4、点击图层按钮,弹出图层面板对话框,解锁图层;5、点击选择工具,移动矩形即可。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),