import { render } from './component'
export class Component {
constructor(config) {
this.template = config.template
this.selector = config.selector
this.el = null
}
render() {
this.el = document.querySelector(this.selector)
if (!this.el) throw new Error(`Component with selector <${this.selector}> wasn't found`)
this.el.innerHTML = this.template
}
}
const MyTr = ({row}) => (
<tr>
{row.map((v, k) => <td key={k}>{v}</td>)}
</tr>
);
class MyTable extends Component {
render() {
const { data } = this.props;
return (
<Table>
{data.map((v, k) => <MyTr data={v} key={k}) />
</Table>
)
}
}