mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 20:38:55 +03:00
useEventEmitter hook instead of manually using code
This commit is contained in:
parent
af514385b2
commit
0d3d837871
1 changed files with 2 additions and 4 deletions
|
@ -22,6 +22,7 @@ import { _t } from '../../../languageHandler';
|
|||
import { Room } from "matrix-js-sdk";
|
||||
import Field from "../elements/Field";
|
||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
import {useEventEmitter} from "../../../hooks/useEventEmitter";
|
||||
|
||||
import {
|
||||
PHASE_UNSENT,
|
||||
|
@ -628,10 +629,7 @@ function VerificationRequest({txnId, request}) {
|
|||
const [timeout, setRequestTimeout] = useState(request.timeout);
|
||||
|
||||
/* Re-render if something changes state */
|
||||
useEffect(() => {
|
||||
request.on("change", updateState);
|
||||
return () => request.off("change", updateState);
|
||||
}, [request]);
|
||||
useEventEmitter(request, "change", updateState);
|
||||
|
||||
/* Keep re-rendering if there's a timeout */
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Reference in a new issue