我有這樣的一個組件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
,因爲它有更多的圖標道具周圍的邏輯,但在這種情況下,我只顯示一個演示。
感謝
啊!當然,什麼是基本概念。謝謝! –