react-instantsearch-dom ::失败的道具类型:无效的道具“ hitComponent”,类型为“对象”,提供给“命中”,预期的“功能”

时间:2019-08-20 05:28:55

标签: reactjs react-instantsearch

我为“命中”创建了一个类组件,并将其添加到另一个使用了angolia react-instantsearch“命中”的文件中。 检查此代码::

<Hits
    hitComponent={Hit}
    className="mb-30"
    showLoadingIndicator
/>

但是给我一个警告::

  

警告:道具类型失败:类型无效的道具hitComponent   object提供给Hits,预期function

我无法将“命中”转换为功能组件。在这里,如何使用类组件值作为函数?

1 个答案:

答案 0 :(得分:1)

不确定,但是您可以尝试以下方法::仅将一个函数包装成一个函数..一个返回组件的函数

<input type="hidden" asp-for="ModelProperty" />

OR

hitComponent={()=><Hit {...props} />}