虚拟化自动完成错误 - 提供给“ForwardRef(ListboxComponent)”的道具“children”无效

发布于 2025-01-13 17:45:31 字数 357 浏览 1 评论 0原文

自动完成虚拟化示例位于 https://mui.com/components/autocomplete/#main-content 会在控制台中产生错误并提示:

失败的道具类型:提供给 ForwardRef(ListboxComponent) 的道具 children 无效,需要 ReactNode。

有谁知道错误指的是什么?该示例有效,但我想知道错误来自哪里,以便更好地理解该示例

The Autocomplete Virtualization example at https://mui.com/components/autocomplete/#main-content produces and error in the console advising:

Failed prop type: Invalid prop children supplied to ForwardRef(ListboxComponent), expected a ReactNode.

Does anyone know what the error is referring to? The example works but I'd like to know where the error is coming from to better understand the example ????

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

_蜘蛛 2025-01-20 17:45:31

该错误似乎直接来自第 109-111 行,其中子项的 propTypes 被专门定义为节点(类型检查)。因为children不是节点,所以会抛出错误。

ListboxComponent.propTypes = {  
      children: PropTypes.node,
};

如果这些行被注释掉,错误就会消失;但是,孩子们应该是节点吗?看起来它们应该按照这些行添加以确保这一点,但为什么它没有工作。有谁知道有任何文档/文章更深入地解释这个示例吗?

The error seems to be coming directly from line 109-111 where the the propTypes of children are specifically being defined as node (Typechecking). Because children is not a node, the error is thrown.

ListboxComponent.propTypes = {  
      children: PropTypes.node,
};

If these lines are commented out, the error goes away; but, are the children supposed to be nodes? It would seem they should be per these lines being added to ensure such but then why is it working without. Does anyone know of any documentation/articles explaining this example in a little more depth?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文