Skip to content

Commit

Permalink
feat: Update RenderToBody support className
Browse files Browse the repository at this point in the history
  • Loading branch information
myxvisual committed Aug 10, 2017
1 parent 3fa4668 commit b97ba6b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/RenderToBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ import * as ReactDOM from "react-dom";

export interface RenderToBodyProps {
style?: React.CSSProperties;
className?: string;
children?: React.ReactElement<any>;
}

export default class RenderToBody extends React.Component<RenderToBodyProps> {
rootElm?: HTMLDivElement;

rootElm = document.createElement("div");
componentDidMount() {
this.rootElm = document.createElement("div");
Object.assign(this.rootElm.style, this.props.style);
const { style, className } = this.props;
Object.assign(this.rootElm, { style, className });

document.body.appendChild(this.rootElm);
this.renderComponent();
}

componentDidUpdate() {
this.renderComponent();
Object.assign(this.rootElm.style, this.props.style);
const { style, className } = this.props;
Object.assign(this.rootElm, { style, className });
}

componentWillUnmount() {
Expand Down

0 comments on commit b97ba6b

Please sign in to comment.