mirror of
https://github.com/wassname/talk.git
synced 2026-07-09 19:58:40 +08:00
28 lines
613 B
JavaScript
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;
|
|
}
|
|
}
|