Skip to content

Commit 74f668d

Browse files
Merge pull request #6 from jantrienes/master
Fix Example in README
2 parents a986332 + c54250f commit 74f668d

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

README.md

+19-15
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,37 @@ Using the [cultofcoders:grapher](https://github.com/cult-of-coders/grapher) quer
55

66
createQueryContainer
77
--------------------
8-
```
9-
// Tasks.jsx
8+
```js
9+
// TaskList.jsx
1010
import React from 'react';
1111
import Tasks from '/imports/api/tasks/collection.js';
1212
import { createQueryContainer } from 'meteor/cultofcoders:grapher-react';
1313

1414
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>
2024
);
2125

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+
});
2731
```
2832

2933
You can pass params directly in the constructor, these params will be passed to the query.
3034

31-
```
32-
import Tasks from './Tasks.jsx';
35+
```js
36+
import TaskList from './Tasks.jsx';
3337

3438
export default () => {
35-
return <Tasks params={{isActive: true}} anyOtherProp="willBePassedToComponent" />
39+
return <TaskList params={{isActive: true}} anyOtherProp="willBePassedToComponent" />
3640
}
3741
```

0 commit comments

Comments
 (0)