Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
SzymczakJ committed Nov 18, 2024
1 parent 1d1fc86 commit 824e698
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/MarkdownTextInput.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,17 @@ const MarkdownTextInput = React.forwardRef<MarkdownTextInput, MarkdownTextInputP
}

const flattenedStyle = useMemo(() => StyleSheet.flatten(style), [style]);
const prevMarkdownStyle = useRef<MarkdownStyle | undefined>(undefined);
const prevMarkdownStyle = useRef<MarkdownStyle>();
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]);
Expand Down

0 comments on commit 824e698

Please sign in to comment.