From 2a3ff0d47c89f678e4eb6ad60c396b36a80f7984 Mon Sep 17 00:00:00 2001 From: Jeremy Gillick Date: Fri, 1 Dec 2023 12:32:05 -0800 Subject: [PATCH] Prevent crash if UI manager isn't ready yet. --- .../components/measure/measure.component.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/devsupport/components/measure/measure.component.tsx b/src/components/devsupport/components/measure/measure.component.tsx index 8abb33f5c..f68b6e02d 100644 --- a/src/components/devsupport/components/measure/measure.component.tsx +++ b/src/components/devsupport/components/measure/measure.component.tsx @@ -74,8 +74,14 @@ export const MeasureElement: React.FC = (props): MeasuringE }; const measureSelf = (): void => { - const node: number = findNodeHandle(ref.current); - UIManager.measureInWindow(node, onUIManagerMeasure); + try { + const node: number = findNodeHandle(ref.current); + UIManager.measureInWindow(node, onUIManagerMeasure); + } catch (error) { + // measureInWindow can throw an exception if the UI manager isn't read yet. + // Try again with a short delay + setTimeout(measureSelf, 100); + } }; if (props.force) {