Wrapper Components
const SampleComponent = () => {
<Parent>
<Child />
</Parent>
};
const Parent = () => {
// You can use class 'bla' or any other classes to handle any style variations for the same markup.
<div className="bla">
{this.props.children}
</div>
};const SampleComponent = () => {
<Wrap tagName="div" content="Hello World" />
};
const Wrap = ({ tagName, content }) => {
const Tag = `${tagName}` // variable name must begin with capital letters
return <Tag>{content}</Tag>
}Related links:
Last updated