<tr> 不能显示为 <ul> 的子项 -- 如何在我的代码中找到确切的位置

<tr> cannot appear as a child of <ul> -- How to find the exact location in my code

提问人:Aaron 提问时间:12/8/2022 最后编辑:Aaron 更新时间:12/8/2022 访问量:34

问:

我知道如何在代码中修复此错误。但是,我似乎找不到它的来源。

我在 EmployeeProfile 和 main 中到处寻找。虽然我似乎找不到它。

我也在 chrome 的控制台 document.querySelectorAll('ul tr') 中尝试过。通过它,什么也没返回

react-dom.development.js:88 Warning: validateDOMNesting(...): <tr> cannot appear as a child of <ul>.
in tr (created by main)
in ul (created by main)
in div (created by main)
in div (created by main)
in div (created by main)
in div (created by main)
in main (created by EmployeeProfile)
in div (created by EmployeeProfile)
in div (created by EmployeeProfile)
in div (created by EmployeeProfile)
in div (created by EmployeeProfile)
in div (created by EmployeeProfile)
in EmployeeProfile (created by Connect(EmployeeProfile))
in Connect(EmployeeProfile) (created by Context.Consumer)
in Route (created by subscriptionroute)
in Switch (created by subscriptionroute)
in subscriptionroute (created by Context.Consumer)
in Route (created by DefaultLayout)
in div (created by DefaultLayout)
in div (created by DefaultLayout)
in DefaultLayout (created by Context.Consumer)
in withRouter(DefaultLayout) (created by Connect(withRouter(DefaultLayout)))
in Connect(withRouter(DefaultLayout)) (created by Context.Consumer)
in Route (created by AuthRoute)
in AuthRoute (created by Connect(AuthRoute))
in Connect(AuthRoute) (created by App)
in Switch (created by App)
in Provider (created by App)
in App (created by Context.Consumer)
in withRouter(App) (created by Connect(withRouter(App)))
in Connect(withRouter(App)) (created by Context.Consumer)
in Route (created by MainApp)
in Switch (created by MainApp)
in Router (created by BrowserRouter)
in BrowserRouter (created by MainApp)
in MainApp
in Provider

我也收到这个错误,我无法找到和修复。我想我可能已经找到了位置,尽管输入密钥并不能解决问题,所以我想也许它不是正确的位置?

enter image description here

enter image description here

enter image description here

enter image description here

我基本上只需要有关如何找到有问题的代码行的帮助。有没有一些js我可以用来找到它?比如document.querySelectorAll('ul tr')?

JavaScript HTML ReactJS 嵌套

评论

1赞 Phil 12/8/2022
代码中不能有那么多元素。使用普通的旧文件搜索找到它们,并找到它们的使用位置。请记住,您可能已将它们包装在其他组件中<tr>
1赞 Phil 12/8/2022
例如,在 VSCode 中使用 Edit -> Find in Files 并搜索 .右键单击任何组件名称,然后选择“转到引用”以查看它们的使用位置<tr
0赞 Aaron 12/8/2022
我找到了它,尽管我还有另一个警告,即警告:列表中的每个孩子都应该有一个唯一的“键”道具。in div (由 main5 创建) in main5 (created by EmployeeProfile) 这将会更难,因为有太多的div。这就是为什么我试图看看是否有更简单的方法来找到警告的违规行
1赞 Phil 12/8/2022
这很简单。查找任何迭代代码,通常是使用 .请参阅了解 React.js 中数组子项的唯一键.map()
0赞 Aaron 12/8/2022
谢谢你,我想我可能已经找到了那个地方,虽然它已经有钥匙了。我更新了问题以向您展示

答: 暂无答案