From 824e69848bb97caa2ed63d9258629f3c21e6eda7 Mon Sep 17 00:00:00 2001 From: Jakub Szymczak Date: Mon, 18 Nov 2024 10:37:29 +0100 Subject: [PATCH] clean up code --- src/MarkdownTextInput.web.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/MarkdownTextInput.web.tsx b/src/MarkdownTextInput.web.tsx index 6c85f6d4..bc2f4ba8 100644 --- a/src/MarkdownTextInput.web.tsx +++ b/src/MarkdownTextInput.web.tsx @@ -127,16 +127,17 @@ const MarkdownTextInput = React.forwardRef StyleSheet.flatten(style), [style]); - const prevMarkdownStyle = useRef(undefined); + const prevMarkdownStyle = useRef(); const memoizedMarkdownStyle = useMemo(() => { - if (prevMarkdownStyle.current && deepCompareMarkdownStyles(prevMarkdownStyle.current ?? {}, markdownStyle ?? {})) { + if (prevMarkdownStyle.current && deepCompareMarkdownStyles(prevMarkdownStyle.current, markdownStyle ?? {})) { return prevMarkdownStyle.current; } return markdownStyle; }, [markdownStyle]); + useEffect(() => { prevMarkdownStyle.current = memoizedMarkdownStyle; - }, [memoizedMarkdownStyle]); // Runs after state is updated + }, [memoizedMarkdownStyle]); // Empty placeholder would collapse the div, so we need to use zero-width space to prevent it const heightSafePlaceholder = useMemo(() => getPlaceholderValue(placeholder), [placeholder]);