我正在尝试在创建-重新应用程序.In中将react-router与reactstrap一起使用我需要为reactstrap使用状态的路由页面,因此我将路由器从变量转换为类。我收到以下警告:警告: validateDOMNesting(...):
我不知道该怎么做,我需要用reactstrap设置路由器导航的样式,所以我按照你下面看到的做了。
有很多原因导致这个方法不起作用:
anywords
(a bunch of li not relevant)
anywords
(then just more of the above)
other than a couple of li coming close to each other at random times and me having to refresh the page sometimes instead of the normal behaviour (auto refresh ) and the warning message i get in the console ,nothin bad happens but when i read about this issue i found out that i shouldn't do it.
发布于 2019-04-11 13:56:52
这是导致错误的代码,
anywords
它被转换为,
所以你得到了错误,
Warning: validateDOMNesting(…): cannot appear as a descendant of
要解决这个问题,只需使用以下方法之一,
anywords
或者,
anywords
发布于 2019-09-15 09:23:38
添加
将属性(以前称为componentClass)添加到原始NavLink以保持样式不变,同时使警告保持静音。
https://react-bootstrap.netlify.com/components/navs/#nav-link-props
或者
查看屏幕截图
原件:
新增:
发布于 2021-02-28 18:52:54
我想提出一个替代方案,它不仅能解决你的问题,而且能给你想要的结果。无论如何,其他人也像我一样偶然发现了这篇文章。
使用react路由器dom提供的Link jsx元素,但添加
为它干杯。这将为您提供react strap正在使用的NavLink jsx的样式。
https://stackoverflow.com/questions/55625431
复制相似问题