git clone [email protected]:c05ad084fc3079351dba.git . && npm install && npm start
Last active
August 29, 2015 14:25
-
-
Save insin/c05ad084fc3079351dba 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
{ | |
"scripts": { | |
"start": "heatpack Todos.js" | |
}, | |
"devDependencies": { | |
"react-heatpack": "^1.4.0" | |
} | |
} |
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
var React = require('react') | |
var Todos = React.createClass({ | |
getInitialState() { | |
return {tasks: [], name: ''} | |
}, | |
handleChange(e) { | |
this.setState({name: e.target.value}) | |
}, | |
handleSubmit(e) { | |
e.preventDefault() | |
var {tasks, name} = this.state | |
this.setState({tasks: [...tasks, {name}], name: ''}) | |
}, | |
render() { | |
return <div className="Todos"> | |
<h3>TODO</h3> | |
<ul> | |
{this.state.tasks.map(task => <li>{task.name}</li>)} | |
</ul> | |
<form onSubmit={this.handleSubmit}> | |
<input value={this.state.name} onChange={this.handleChange} required/> | |
<button>Add task</button> | |
</form> | |
</div> | |
} | |
}) | |
module.exports = Todos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment