import React from 'react';
import ReactDOM from 'react-dom';

import App from './App';

class View {
	constructor(main) {
		this.main_ = main
		this.el_ = document.createElement("div");
		let root = document.getElementById('root'); 
		root.appendChild(this.el_);
	}

	render() {
		let app_id = this.main_.app_id;
		ReactDOM.render(
		  <App app_id={app_id}/>,
		  this.el_
		);
	}

	destroy() {
		let root = document.getElementById('root'); 
		root.removeChild(this.el_);
		this.el_ = null;
	}
}

export default View;