diff --git a/.changeset/smart-eyes-enjoy.md b/.changeset/smart-eyes-enjoy.md new file mode 100644 index 000000000..414abbb78 --- /dev/null +++ b/.changeset/smart-eyes-enjoy.md @@ -0,0 +1,5 @@ +--- +'slate-react': patch +--- + +fix forced update in TextString in case of double render diff --git a/packages/slate-react/src/components/string.tsx b/packages/slate-react/src/components/string.tsx index c6a228b36..b8ee407fe 100644 --- a/packages/slate-react/src/components/string.tsx +++ b/packages/slate-react/src/components/string.tsx @@ -59,17 +59,17 @@ const TextString = (props: { text: string; isTrailing?: boolean }) => { const { text, isTrailing = false } = props const ref = useRef(null) - const forceUpdateFlag = useRef(false) + const forceUpdateCount = useRef(0) if (ref.current && ref.current.textContent !== text) { - forceUpdateFlag.current = !forceUpdateFlag.current + forceUpdateCount.current += 1 } // This component may have skipped rendering due to native operations being // applied. If an undo is performed React will see the old and new shadow DOM // match and not apply an update. Forces each render to actually reconcile. return ( - + {text} {isTrailing ? '\n' : null}