Created
March 12, 2017 10:16
-
-
Save tmeasday/7f3b964c63a580df23e3cd41083186a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react'; | |
import { propType } from 'graphql-anywhere'; | |
import gql from 'graphql-tag'; | |
import Task from './Task'; | |
function TaskList( | |
{ tasks, onSnoozeTask, onPinTask, onArchiveTask, onUpdateTaskTitle }, | |
) { | |
const events = { | |
onSnoozeTask, | |
onPinTask, | |
onArchiveTask, | |
onUpdateTaskTitle, | |
}; | |
return ( | |
<div className="list-items"> | |
{tasks.map(task => <Task key={task.id} task={task} {...events} />)} | |
</div> | |
); | |
} | |
TaskList.fragments = { | |
task: ( | |
gql` | |
fragment TaskListTaskFragment on Task { | |
id | |
updatedAt | |
...TaskFragment | |
} | |
${Task.fragments.task} | |
` | |
), | |
}; | |
TaskList.propTypes = { | |
tasks: PropTypes.arrayOf(propType(Task.fragments.task)).isRequired, | |
onSnoozeTask: PropTypes.func, | |
onPinTask: PropTypes.func, | |
onArchiveTask: PropTypes.func, | |
onUpdateTaskTitle: PropTypes.func.isRequired, | |
}; | |
export default TaskList; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment