@@ -5,33 +5,37 @@ Using the [cultofcoders:grapher](https://github.com/cult-of-coders/grapher) quer
5
5
6
6
createQueryContainer
7
7
--------------------
8
- ```
9
- // Tasks .jsx
8
+ ``` js
9
+ // TaskList .jsx
10
10
import React from ' react' ;
11
11
import Tasks from ' /imports/api/tasks/collection.js' ;
12
12
import { createQueryContainer } from ' meteor/cultofcoders:grapher-react' ;
13
13
14
14
const query = Tasks .createQuery ({
15
- title: 1
16
- })
17
-
18
- const Tasks = ({loading, error, tasks}) => (
19
- _.map(tasks, task => <div>{task.title}</div>)
15
+ title: 1 ,
16
+ });
17
+
18
+ const TaskList = ({loading, error, tasks}) => (
19
+ < div>
20
+ {
21
+ _ .map (tasks, task => < div key= {task ._id }> {task .title }< / div> )
22
+ }
23
+ < / div>
20
24
);
21
25
22
- export default createQueryContainer(query, Tasks , {
23
- reactive: true // defaults to false, will use pub/sub system
24
- dataProp: 'tasks' // defaults to 'data',
25
- single: false // defaults to false, when you expect a single document, like you filter by _id, use this.
26
- })
26
+ export default createQueryContainer (query, TaskList , {
27
+ reactive: true , // defaults to false, will use pub/sub system
28
+ dataProp: ' tasks' , // defaults to 'data'
29
+ single: false , // defaults to false, when you expect a single document, like you filter by _id, use this.
30
+ });
27
31
```
28
32
29
33
You can pass params directly in the constructor, these params will be passed to the query.
30
34
31
- ```
32
- import Tasks from './Tasks.jsx';
35
+ ``` js
36
+ import TaskList from ' ./Tasks.jsx' ;
33
37
34
38
export default () => {
35
- return <Tasks params={{isActive: true}} anyOtherProp="willBePassedToComponent" />
39
+ return < TaskList params= {{isActive: true }} anyOtherProp= " willBePassedToComponent" / >
36
40
}
37
41
```
0 commit comments