提问人:Shuxrat Omonqulov 提问时间:1/31/2023 更新时间:2/1/2023 访问量:39
警告:如果从渲染中返回 Component 而不是 <Component />,则可能会发生这种情况
Warning: This may happen if you return a Component instead of <Component /> from render
问:
const PersonDetails = () => {
return (
<SwapiServiceConsumer>
{({ getPerson }) => {
return witdDetails(
withChildFunc(ItemDetails, withChildDetails(arrPersonDetails)),
getPerson
);
}}
</SwapiServiceConsumer>
);
};
嗨,你好。请告诉我我的错误在哪里。我收到以下错误:警告:函数作为 React 子项无效。如果从渲染中返回 Component 而不是 <Component />,则可能会发生这种情况。或者,也许您打算调用此函数而不是返回它。
Here witdDetails, withChildFunc and withChildDetails is HOC
If anyone knows the swapi, I have the PlanetList but the PlanetDetails are not visible.
答:
0赞
Calixte de Tourris
2/1/2023
#1
这个错误非常明确,你不能将函数作为 React Child 返回。
要么确保该函数返回一个有效的 React 组件,要么您可以创建一个新组件,该组件将细节作为道具在 DOM 上呈现它们并返回它。withDetails
评论
0赞
Shuxrat Omonqulov
2/2/2023
嗨,你好。感谢您的回复。但我不这么认为。我会再试一次。
评论