Using Arrays instead of objects for Hooks

This commit is contained in:
Belen Curcio
2017-04-12 13:45:42 -03:00
parent ac632a69d2
commit 0254086c28
2 changed files with 52 additions and 51 deletions
@@ -7,19 +7,15 @@ class OffTopicCheckbox extends React.Component {
handleChange = (e) => {
if (e.target.checked) {
this.props.registerHook({
postSubmit: {
addTag: (data) => {
const {comment} = data.createComment;
this.props.addCommentTag({
id: comment.id,
tag: 'OFF_TOPIC',
});
}
}
this.addCommentTagHook = this.props.registerHook('postSubmit', (data) => {
const {comment} = data.createComment;
this.props.addCommentTag({
id: comment.id,
tag: 'OFF_TOPIC'
});
})
} else {
this.props.unregisterHook('postSubmit', 'addTag');
this.props.unregisterHook(this.addCommentTagHook);
}
}