Last active
September 2, 2017 13:22
-
-
Save enkot/a01075ed19cd8fb861c3e291a5f1c6b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
let id = 0; | |
class App extends Component { | |
state = { cards: [] } | |
addCard(text) { | |
this.setState({ | |
cards: [...this.state.cards, { | |
id: id++, | |
text | |
}] | |
}) | |
} | |
changeCardStatus = (id, status) => { /* TODO: change card status */ } | |
removeCard = (id) => { /* TODO: remove card */ } | |
render() { | |
return ( | |
<div> | |
<input ref="name" /> | |
<button onClick={() => this.addCard(this.refs.name.value)}> | |
Add | |
</button> | |
{this.state.cards.map((card) => | |
<p key={card.id}>{card.text}</p> | |
)} | |
</div> | |
); | |
} | |
} | |
render(<App />, document.getElementById('app')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment