Reputation: 31625
If I have a component, like
function Foo(){
return <h1>Hey</h1>
}
What I can do is something like
const MyElement = Foo
return (<MyElement />)
But How can I get this reference of a div
element?
I want to do something like
const WrapComponent = foo ? MyComponent : div
...
<WrapComponent>
{/*anything*/}
</WrapComponent>
I just don't know how do that with a div
element.
Upvotes: 0
Views: 148
Reputation: 10538
DOM elements like that are written as strings.
const WrapComponent = foo ? MyComponent : "div";
...
<WrapComponent>
...
</WrapComponent>
Upvotes: 1