From 6ed07eaef06cfe8710f876bc6295b1982cd3dff4 Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Mon, 25 Jul 2022 14:03:17 +0800 Subject: [PATCH] delay context bar width/height access --- .../src/components/ContextBar/ContextBar.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tldraw/apps/tldraw-logseq/src/components/ContextBar/ContextBar.tsx b/tldraw/apps/tldraw-logseq/src/components/ContextBar/ContextBar.tsx index 42f567689..7bf907e95 100644 --- a/tldraw/apps/tldraw-logseq/src/components/ContextBar/ContextBar.tsx +++ b/tldraw/apps/tldraw-logseq/src/components/ContextBar/ContextBar.tsx @@ -40,10 +40,12 @@ const _ContextBar: TLContextBarComponent = ({ shapes, offsets }) => { }, []) React.useLayoutEffect(() => { - const elm = rContextBar.current - if (!elm) return - const { offsetWidth, offsetHeight } = elm - rSize.current = [offsetWidth, offsetHeight] + setTimeout(() => { + const elm = rContextBar.current + if (!elm) return + const { offsetWidth, offsetHeight } = elm + rSize.current = [offsetWidth, offsetHeight] + }) }) React.useLayoutEffect(() => {