我有一个组件Foo.js:
// 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>
Run Code Online (Sandbox Code Playgroud)
然后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>
)
}
Run Code Online (Sandbox Code Playgroud)
我想在<IconStar>里面渲染<Button>,我该怎么做?
我不能通过这个,this.prop.children因为它在图标道具周围有更多的逻辑,但在这种情况下我只显示一个演示.
谢谢