mirror of
https://github.com/captbaritone/webamp.git
synced 2026-01-24 02:36:00 +00:00
22 lines
579 B
JavaScript
22 lines
579 B
JavaScript
import React from "react";
|
|
import ReactDOM from "react-dom";
|
|
|
|
export default class Desktop extends React.Component {
|
|
componentWillUnmount() {
|
|
document.body.removeChild(this._desktopNode);
|
|
this._desktopNode = null;
|
|
}
|
|
|
|
_getNode() {
|
|
if (this._desktopNode == null) {
|
|
this._desktopNode = document.createElement("div");
|
|
this._desktopNode.classList.add("webamp-desktop");
|
|
document.body.appendChild(this._desktopNode);
|
|
}
|
|
return this._desktopNode;
|
|
}
|
|
|
|
render() {
|
|
return ReactDOM.createPortal(this.props.children, this._getNode());
|
|
}
|
|
}
|