Permalink
Browse files

Step 3.4: Modify App component to get tasks from collection

  • Loading branch information...
tmeasday authored and hwillson committed Mar 18, 2016
1 parent 6561f49 commit e618d9e3650682448456219b32d29ee9d0023925
Showing with 11 additions and 10 deletions.
  1. +11 −10 imports/ui/App.js
@@ -1,19 +1,14 @@
import React, { Component } from 'react';
import { withTracker } from 'meteor/react-meteor-data';

import { Tasks } from '../api/tasks.js';

import Task from './Task.js';

// App component - represents the whole app
export default class App extends Component {
getTasks() {
return [
{ _id: 1, text: 'This is task 1' },
{ _id: 2, text: 'This is task 2' },
{ _id: 3, text: 'This is task 3' },
];
}

class App extends Component {
renderTasks() {

This comment has been minimized.

@Raghees-butt

Raghees-butt Jul 9, 2018

works with render(){

return this.getTasks().map((task) => (
return this.props.tasks.map((task) => (
<Task key={task._id} task={task} />

This comment has been minimized.

@aaronxie7

aaronxie7 Jun 25, 2018

bug here, correct code is return <Task key={task._id} task={task} />

This comment has been minimized.

@coagmano

coagmano Jul 22, 2018

Not a bug. Arrow functions without curly braces return implicitly. In this example, the parentheses (...) keep the return behaviour across multiple lines

It's a bit harder to spot return bugs in arrow functions, so many choose to include the return for readability, but it's quite common in the React community to leave it out and write jsx this way

));
}
@@ -32,3 +27,9 @@ export default class App extends Component {
);
}
}

export default withTracker(() => {
return {
tasks: Tasks.find({}).fetch(),
};
})(App);

0 comments on commit e618d9e

Please sign in to comment.