React
by Artur Stambultsian
HTML
<div id="app"></div>
React
class App extends React.Component {
constructor (props) {
this.state = {
active: false,
list: [{
id: 1,
title: 'Вася'
}, {
id: 2,
title: 'Таня'
}, {
id: 3,
title: 'Джош'
}]
}
}
onClick () {
this.state.active = true
}
render() {
return (
<div>
<ol>
{this.state.list.map(item => (
<li>
{item.title}
</li>
))}
</ol>
<button onClick={() => this.onClick()}>Добавить</button>
</div>
)
}
}
ReactDOM.render(<App />, document.querySelector("#app"))