当组件作为另一个组件的道具传递时,如何通过道具?
我的组件如下:
const ArrowDownIcon = (name:string) => (
<MaterialCommunityIcons
name={name}
size={50}
color={theme.colors.text}
/>
);
然后,我应该将上述组件作为道具传递给以下组件:
const Dropdown = () =>{
<DropDownPicker
ArrowDownIconComponent={ArrowDownIcon}
/>
}
但是它不起作用,因为我应该将name
的道具传递给arrowdowniconcomponent
。有人可以向我解释一下该怎么做吗?
I have a component as follows:
const ArrowDownIcon = (name:string) => (
<MaterialCommunityIcons
name={name}
size={50}
color={theme.colors.text}
/>
);
Then I should pass the above component as a prop to the following component:
const Dropdown = () =>{
<DropDownPicker
ArrowDownIconComponent={ArrowDownIcon}
/>
}
But it doesn't work, since I should pass the prop of name
to the ArrowDownIconComponent
. Can somebody please explain me how to do this please?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里没有错,在
下拉picker
中,您只需要渲染arrowdowniconcomponent
您也可以使用这种方式使用
Nothing wrong here, in
DropDownPicker
you just have to render yourArrowDownIconComponent
You can also use it this way
您可以以这种方式将名称作为道具传递
you can pass the name as a prop in this way