From 6c68c00578145f48a8983e9853e0709a68628d51 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Thu, 21 Apr 2022 16:20:41 -0400 Subject: [PATCH] Use useRefMerger in Input to avoid re-renders --- ts/components/Input.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ts/components/Input.tsx b/ts/components/Input.tsx index a4e335d4a..30c922d3b 100644 --- a/ts/components/Input.tsx +++ b/ts/components/Input.tsx @@ -14,7 +14,7 @@ import classNames from 'classnames'; import * as grapheme from '../util/grapheme'; import type { LocalizerType } from '../types/Util'; import { getClassNamesFor } from '../util/getClassNamesFor'; -import { refMerger } from '../util/refMerger'; +import { useRefMerger } from '../hooks/useRefMerger'; import { byteLength } from '../Bytes'; export type PropsType = { @@ -84,6 +84,7 @@ export const Input = forwardRef< const valueOnKeydownRef = useRef(value); const selectionStartOnKeydownRef = useRef(value.length); const [isLarge, setIsLarge] = useState(false); + const refMerger = useRefMerger(); const maybeSetLarge = useCallback(() => { if (!expandable) {