Reputation: 110960
I'm using React 16.2. I have a component to render a popup window which works like so:
<WindowPopOut
trigger={<Button>Open Window PopUp</Button>}
....
/>
And then...
class WindowPopOut extends Component {
...
render() {
const clonedTrigger = React.cloneElement(trigger, {
onClick: this.handleTriggerClick,
});
return (
<div>
{clonedTrigger}
...
</div>
);
}
}
The problem is this renders in the DOM like so:
<div><Button>Open Window PopUp</Button></div>
How can I make WindowPopOut
render without the DIV wrapping? So the component simply renders:
<Button>Open Window PopUp</Button>
Upvotes: 0
Views: 66
Reputation: 2407
Have you tried wrapping with a React.Fragment
?
return (
<React.Fragment>
{clonedTrigger}
...
</React.Fragment>
);
Upvotes: 3