Carousel 如何将返回组件的函数作为道具传递?
我需要创建自定义列表项的旋转木马,并且我已经将旋转木马组件库(react native snap carousel)中的一个导入到项目中,但是旋转木马组件需要返回组件的道具,我们需要将其呈现为旋转木马项列表。 所以我送了这样的道具Carousel 如何将返回组件的函数作为道具传递?,carousel,clojurescript,reagent,Carousel,Clojurescript,Reagent,我需要创建自定义列表项的旋转木马,并且我已经将旋转木马组件库(react native snap carousel)中的一个导入到项目中,但是旋转木马组件需要返回组件的道具,我们需要将其呈现为旋转木马项列表。 所以我送了这样的道具 [carousel {:render-item (fn [] [my-custom-item]) ...otherprops... }] 但这是一个错误 Element type is invalid: expected a stri
[carousel {:render-item (fn [] [my-custom-item])
...otherprops... }]
但这是一个错误
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
如何将道具作为返回元素的函数发送
这是如何在js上调用carousel组件
<Carousel
ref={(c) => { this._carousel = c; }}
data={this.state.entries}
renderItem={this._renderItem}
sliderWidth={sliderWidth}
itemWidth={itemWidth}
/>
{this._carousel=c;}
数据={this.state.entries}
renderItem={this.\u renderItem}
sliderWidth={sliderWidth}
itemWidth={itemWidth}
/>
旋转木马组件期望从呈现项函数返回一个react元素或字符串。但您返回的是纯试剂成分
您需要使用试剂的功能将试剂成分转换为反应成分:
[carousel {:render-item (fn [] (reagent/as-element [my-custom-item]))
...otherprops... }]