我为“命中”创建了一个类组件,并将其添加到另一个使用了angolia react-instantsearch“命中”的文件中。 检查此代码::
<Hits
hitComponent={Hit}
className="mb-30"
showLoadingIndicator
/>
但是给我一个警告::
警告:道具类型失败:类型无效的道具
hitComponent
object
提供给Hits
,预期function
。
我无法将“命中”转换为功能组件。在这里,如何使用类组件值作为函数?
答案 0 :(得分:1)
不确定,但是您可以尝试以下方法::仅将一个函数包装成一个函数..一个返回组件的函数
<input type="hidden" asp-for="ModelProperty" />
OR
hitComponent={()=><Hit {...props} />}