Skip to content

Commit ccb854f

Browse files
committed
FYI: Modify the tagname according to the parameter in a component
Closes #28
1 parent 4f7ec3f commit ccb854f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ux-variations/05.wrapper-components.md

+15
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,20 @@ const Parent = () => {
2020
</div>
2121
};
2222
```
23+
24+
FYI - Wrapper component can also be made accept a tag name and then used to generate the HTML element.
25+
However, usually this is not recommended because you can't add attributes/props to it.
26+
27+
```javascript
28+
const SampleComponent = () => {
29+
<Wrap tagName="div" content="Hello World" />
30+
};
31+
32+
const Wrap = ({ tagName, content }) => {
33+
const Tag = `${tagName}` // variable name must begin with capital letters
34+
return <Tag>{content}</Tag>
35+
}
36+
```
37+
2338
### Related links:
2439
- [Slides from my talk: Building Multi-tenant UI with React](https://speakerdeck.com/vasa/building-multitenant-ui-with-react-dot-js)

0 commit comments

Comments
 (0)