Adding preSubmit hoojs

This commit is contained in:
Belen Curcio
2017-04-11 12:42:48 -03:00
parent 014c23bb95
commit aeaa9ae80f
2 changed files with 15 additions and 3 deletions
+15 -2
View File
@@ -56,11 +56,24 @@ class CommentBox extends Component {
}
!isReply && updateCountCache(assetId, countCache + 1);
// Execute preSubmit Hooks
Object.keys(this.state.hooks.preSubmit).forEach(hook => {
// Hooks MUST be functions
if (typeof this.state.hooks.preSubmit[hook] === 'function') {
this.state.hooks.preSubmit[hook]();
} else {
console.warn(`Hooks MUST be functions. preSubmit ${hook} will not be executed.`);
}
});
postItem(comment, 'comments')
.then(({data}) => {
const postedComment = data.createComment.comment;
// Execute postComment Hooks
// Execute postSubmit Hooks
Object.keys(this.state.hooks.postSubmit).forEach(hook => {
@@ -69,7 +82,7 @@ class CommentBox extends Component {
if (typeof this.state.hooks.postSubmit[hook] === 'function') {
this.state.hooks.postSubmit[hook](data);
} else {
console.warn(`Hooks MUST be functions. ${hook} will not be executed.`);
console.warn(`Hooks MUST be functions. postSubmit ${hook} will not be executed.`);
}
});
@@ -29,7 +29,6 @@ class OffTopicCheckbox extends React.Component {
return (
<div className={styles.offTopic}>
<label>
{/*{console.log(this.props)}*/}
<input type="checkbox" onChange={this.handleChange}/>
Off-Topic
</label>