我有这样的一个组件Foo.js
:阵营:通成分的道具,而无需使用this.props.children
// a svg component with a star.svg icon
import { IconStar } from 'react-svg-icons';
// call a button with a custom icon
<Button icon={ IconStar }> Click to trigger </Button>
,然后button.js
我:
render() {
const theIcon = this.props.icon;
return (
<button>
{this.props children}
{icon() /*this works but i can't pass props inside it*/}
<theIcon className={ Styles.buttonIcon } />
</button>
)
}
我想渲染<IconStar>
内<Button>
,我该怎么做?
我不能通过这个作为this.prop.children
,因为它有更多的图标道具周围的逻辑,但在这种情况下,我只显示一个演示。
感谢
啊!当然,什么是基本概念。谢谢! –