From 0d3d837871518200f7ad2d01894b93cd5cd66611 Mon Sep 17 00:00:00 2001 From: Zoe Date: Mon, 24 Feb 2020 13:44:04 +0000 Subject: [PATCH] useEventEmitter hook instead of manually using code --- src/components/views/dialogs/DevtoolsDialog.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/components/views/dialogs/DevtoolsDialog.js b/src/components/views/dialogs/DevtoolsDialog.js index dc99ed680c..0420c038ca 100644 --- a/src/components/views/dialogs/DevtoolsDialog.js +++ b/src/components/views/dialogs/DevtoolsDialog.js @@ -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(() => {