Files
talk/plugins/talk-plugin-toxic-comments/client/components/CheckToxicityHook.js
T
2017-09-06 22:11:48 +07:00

28 lines
613 B
JavaScript

import React from 'react';
export default class CheckToxicityHook extends React.Component {
checked = false;
componentDidMount() {
this.toxicityPreHook = this.props.registerHook('preSubmit', (input) => {
if (!this.checked) {
input.checkToxicity = true;
this.checked = true;
}
});
this.toxicityPostHook = this.props.registerHook('postSubmit', () => {
this.checked = false;
});
}
componentWillUnmount() {
this.props.unregisterHook(this.toxicityPreHook);
this.props.unregisterHook(this.toxicityPostHook);
}
render() {
return null;
}
}