Skip to content
Permalink
Browse files

Step 3 of TODO App with React tutorial - use a Mongo collection for s…

…toring TODO items
  • Loading branch information
itamaro committed Nov 28, 2015
1 parent b0d76bc commit a8f2845dfc8b12c555b39f46f6c681c96de9b974
Showing with 14 additions and 7 deletions.
  1. +11 −7 App.jsx
  2. +3 −0 simple-todos-react.jsx
18 App.jsx
@@ -1,15 +1,19 @@
// App component - represents the whole app
App = React.createClass({
getTasks() {
return [
{ _id: 1, text: "This is task 1" },
{ _id: 2, text: "This is task 2" },
{ _id: 3, text: "This is task 3" }
];

// This mixin makes the getMeteorData method work
mixins: [ReactMeteorData],

// Loads items from the Tasks collection and puts them on this.data.tasks
getMeteorData() {
return {
tasks: Tasks.find({}).fetch()
}
},

renderTasks() {
return this.getTasks().map((task) => {
// Get tasks from this.data.tasks
return this.data.tasks.map((task) => {
return <Task key={task._id} task={task} />;
});
},
@@ -1,3 +1,6 @@
// Define a collection to hold our tasks
Tasks = new Mongo.Collection("tasks");

if (Meteor.isClient) {
// This code is executed on the client only

0 comments on commit a8f2845

Please sign in to comment.
You can’t perform that action at this time.