We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 12d6c86 commit 7f1d563Copy full SHA for 7f1d563
src/RenderToBody.tsx
@@ -1,5 +1,6 @@
1
import * as React from "react";
2
import * as ReactDOM from "react-dom";
3
+import IS_NODE_ENV from "./common/nodeJS/IS_NODE_ENV";
4
5
export interface RenderToBodyProps {
6
style?: React.CSSProperties;
@@ -8,8 +9,10 @@ export interface RenderToBodyProps {
8
9
}
10
11
export default class RenderToBody extends React.Component<RenderToBodyProps> {
- rootElm = document.createElement("div");
12
+ rootElm = IS_NODE_ENV ? null : document.createElement("div");
13
+
14
componentDidMount() {
15
+ if (IS_NODE_ENV) this.rootElm = document.createElement("div");
16
const { style, className } = this.props;
17
Object.assign(this.rootElm.style, style);
18
if (className) this.rootElm.setAttribute("class", className);
0 commit comments