Created
March 27, 2016 12:46
-
-
Save dai-shi/909bac9950f1449af5ca 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
| diff --git a/imports/ui/App.jsx b/imports/ui/App.jsx | |
| index c452da9..332bd6e 100644 | |
| --- a/imports/ui/App.jsx | |
| +++ b/imports/ui/App.jsx | |
| @@ -1,4 +1,5 @@ | |
| import React, { Component, PropTypes } from 'react'; | |
| +import ReactDOM from 'react-dom'; | |
| import { createContainer } from 'meteor/react-meteor-data'; | |
| import { Tasks } from '../api/tasks.js'; | |
| @@ -7,6 +8,21 @@ import Task from './Task.jsx'; | |
| // App component - represents the whole app | |
| class App extends Component { | |
| + handleSubmit(event) { | |
| + event.preventDefault(); | |
| + | |
| + // Find the text field via the React ref | |
| + const text = ReactDOM.findDOMNode(this.refs.textInput).value.trim(); | |
| + | |
| + Tasks.insert({ | |
| + text, | |
| + createdAt: new Date(), // current time | |
| + }); | |
| + | |
| + // Clear form | |
| + ReactDOM.findDOMNode(this.refs.textInput).value = ''; | |
| + } | |
| + | |
| renderTasks() { | |
| return this.props.tasks.map((task) => ( | |
| <Task key={task._id} task={task} /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment