rsnext/examples/with-portals/components/Portal.js
Darryl f177be9e05 Fix bug report with-portals example #5694 (#5714)
I'm trying to contribute on resolving issues,
hope this help.

Fixes #5694
2018-11-21 09:25:00 +01:00

17 lines
373 B
JavaScript

import React from 'react'
import ReactDOM from 'react-dom'
export class Portal extends React.Component {
componentDidMount () {
this.element = document.querySelector(this.props.selector)
this.forceUpdate()
}
render () {
if (this.element === undefined) {
return null
}
return ReactDOM.createPortal(this.props.children, this.element)
}
}