From e5a4fbc1cde1ac9bfee7ada76d31ed1e6f2015d3 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 12 May 2017 12:07:55 -0300 Subject: [PATCH] DOCS Hooks --- docs/frontend/HOOKS.md | 0 docs/frontend/PLUGINS.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 docs/frontend/HOOKS.md diff --git a/docs/frontend/HOOKS.md b/docs/frontend/HOOKS.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/frontend/PLUGINS.md b/docs/frontend/PLUGINS.md index 8377d0359..4d993c0be 100644 --- a/docs/frontend/PLUGINS.md +++ b/docs/frontend/PLUGINS.md @@ -170,6 +170,34 @@ Our `style.css` should could look like this. } ``` +## Plugin Hooks +The plugins injected in the CommentBox such as `commentInputDetailArea` will inherit through props tools for handling hooks. + +### Available hook types: +`preSubmit` : To perform actions before submitting the comment. +`postSubmit` : To perform actions after submitting the comment. + +### Register Hooks +`registerHook` is a function that takes: the hook type, a hook function and returns the hook data. + +#### Usage: +```js + this.addCommentTagHook = this.props.registerHook('postSubmit', (data) => { + const {comment} = data.createComment; + this.props.addCommentTag({ + id: comment.id, + tag: 'OFF_TOPIC' + }); + }); +``` + +### Unregister Hooks + +`unregisterHook` will remove the hook. + +```js + this.props.unregisterHook(this.addCommentTagHook); +``` ### The server folder and the index file Read more about the `/server` and how to extend Talk here.