mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
f177be9e05
I'm trying to contribute on resolving issues, hope this help. Fixes #5694
18 lines
373 B
JavaScript
18 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)
|
|
}
|
|
}
|