delay context bar width/height access

pull/6345/head
Peng Xiao 2022-07-25 14:03:17 +08:00
parent ac27e5e6f8
commit 6ed07eaef0
1 changed files with 6 additions and 4 deletions

View File

@ -40,10 +40,12 @@ const _ContextBar: TLContextBarComponent<Shape> = ({ shapes, offsets }) => {
}, []) }, [])
React.useLayoutEffect(() => { React.useLayoutEffect(() => {
const elm = rContextBar.current setTimeout(() => {
if (!elm) return const elm = rContextBar.current
const { offsetWidth, offsetHeight } = elm if (!elm) return
rSize.current = [offsetWidth, offsetHeight] const { offsetWidth, offsetHeight } = elm
rSize.current = [offsetWidth, offsetHeight]
})
}) })
React.useLayoutEffect(() => { React.useLayoutEffect(() => {