App.jsx 745 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // App component : represents the whole app.
  2. App = React.createClass({
  3. // This mixin makes the getMeteorData work.
  4. mixins: [ReactMeteorData],
  5. // Loads items from the Tasks collection and puts them on this.data.tasks.
  6. getMeteorData() {
  7. let result = {
  8. tasks: Tasks.find({}).fetch()
  9. };
  10. // Meteor._debug("result", result);
  11. return result;
  12. },
  13. renderTasks() {
  14. return this.data.tasks.map((task) => {
  15. // Meteor._debug(task._id);
  16. return <Task key={task._id} task={task} />;
  17. });
  18. },
  19. render() {
  20. return (
  21. <div className="container">
  22. <header>
  23. <h1>Todo list</h1>
  24. </header>
  25. <ul>
  26. {this.renderTasks()}
  27. </ul>
  28. </div>
  29. );
  30. }
  31. });