all files / components/ RootModal.js

100% Statements 14/14
100% Branches 0/0
100% Functions 5/5
100% Lines 13/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                                  
import React, { Component, PropTypes } from 'react';
import ReactDOM from 'react-dom';
 
class RootModal extends Component {
  static propTypes = {
    children: PropTypes.object,
  };
 
  componentDidMount() {
    this.modalTarget = document.createElement('div');
    this.modalTarget.className = 'intl-tel-input iti-container';
    document.body.appendChild(this.modalTarget);
    this._render();
  }
 
  componentWillUpdate() {
    this._render();
  }
 
  componentWillUnmount() {
    ReactDOM.unmountComponentAtNode(this.modalTarget);
    document.body.removeChild(this.modalTarget);
  }
 
  _render() {
    ReactDOM.render(
      <div>{this.props.children}</div>,
      this.modalTarget
    );
  }
 
  render() {
    return <noscript />;
  }
}
 
export default RootModal;