import React, { Component } from 'react';
import './App.css';
class Content extends Component {
getTable(){
for(let i; i<=6; i++){
let tr = document.createElement('tr');
document.getElementById('table').appendChild(tr);
}
}
render() {
return (
<div className="Content">
<table id='table'>
{this.getTable}
</table>
</div>
);
}
}
export default Content;
<div id="root"></div>
class Table1 extends React.Component {
render() {
return (
<div className="Content">
<span> Table </span>
<table id='table'>
{
this.props.data.map(elem=>{
return (<tr> {elem} </tr>)
})
}
</table>
</div>
);
}
}
ReactDOM.render(
<Table1 data={[1,2,3,4,5]}/>,
root
)
class Header extends React.Component {
constructor() {
super();
this.state = {
items: [
{ name: 'Google', link: 'https://google.com' },
{ name: 'Yandex', link: 'https://yandex.com' }
] };
}
render() {
const list = this.state.items.map((item, index) => {
return <li key={index}><a href={item.link}>{item.name}</a></li>;
});
return <ul>
{list}
</ul>;
}
}