Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React from 'react';
- export default React.createClass({
- getInitialState: function() {
- return {
- list: [],
- text: ''
- }
- },
- // ["take out trash", "call your mom", "tell mom you love her"]
- // "mow the lawn"
- // ["mow the lawn", "take out trash", "call your mom", "tell mom you love her"]
- handleChange: function(e) {
- this.setState({
- text: e.target.value
- })
- },
- handleSubmit: function(e) {
- e.preventDefault()
- this.setState({
- list: [this.state.text, ...this.state.list],
- text: ''
- })
- },
- render: function () {
- return (
- <form onSubmit={this.handleSubmit}>
- <input type="text" onChange={this.handleChange} value={this.state.text} />
- </form>
- )
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement