From ca879b8b7b7388d10eab8af6f5e59aee0124c0bb Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 9 Jul 2024 17:43:34 +0800 Subject: [PATCH 1/2] update the selection only if the prop is updated --- src/components/Composer/index.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index a41f983434d8..9e8de034186d 100755 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -116,12 +116,10 @@ function Composer( }, [shouldClear, onClear]); useEffect(() => { - setSelection((prevSelection) => { - if (!!prevSelection && selectionProp.start === prevSelection.start && selectionProp.end === prevSelection.end) { - return; - } - return selectionProp; - }); + if (!!selection && selectionProp.start === selection.start && selectionProp.end === selection.end) { + return; + } + setSelection(selectionProp); }, [selectionProp]); /** From 7e3dce3a5d89f32f7a15e623df68845a55806870 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 10 Jul 2024 11:45:48 +0800 Subject: [PATCH 2/2] suppress lint --- src/components/Composer/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Composer/index.tsx b/src/components/Composer/index.tsx index 9e8de034186d..3889c8597843 100755 --- a/src/components/Composer/index.tsx +++ b/src/components/Composer/index.tsx @@ -120,6 +120,7 @@ function Composer( return; } setSelection(selectionProp); + // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps }, [selectionProp]); /**