From d49286bddc543a875bd5ebad36c05a0d6b74a29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Klomp?= Date: Fri, 24 May 2024 13:47:54 +0200 Subject: [PATCH] Remove defaultProps from MeasureElement component --- .../components/measure/measure.component.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/components/devsupport/components/measure/measure.component.tsx b/src/components/devsupport/components/measure/measure.component.tsx index 8abb33f5c..ad6ddf1d3 100644 --- a/src/components/devsupport/components/measure/measure.component.tsx +++ b/src/components/devsupport/components/measure/measure.component.tsx @@ -44,7 +44,12 @@ export type MeasuringElement = React.ReactElement; * but `force` property may be used to measure any time it's needed. * DON'T USE THIS FLAG IF THE COMPONENT RENDERS FIRST TIME OR YOU KNOW `onLayout` WILL BE CALLED. */ -export const MeasureElement: React.FC = (props): MeasuringElement => { +export const MeasureElement: React.FC = ({ + force = false, + shouldUseTopInsets = false, + onMeasure, + children +}): MeasuringElement => { const ref = React.useRef(); @@ -67,9 +72,9 @@ export const MeasureElement: React.FC = (props): MeasuringE if (!w && !h) { measureSelf(); } else { - const originY = props.shouldUseTopInsets ? y + StatusBar.currentHeight || 0 : y; + const originY = shouldUseTopInsets ? y + StatusBar.currentHeight || 0 : y; const frame: Frame = bindToWindow(new Frame(x, originY, w, h), Frame.window()); - props.onMeasure(frame); + onMeasure(frame); } }; @@ -78,13 +83,9 @@ export const MeasureElement: React.FC = (props): MeasuringE UIManager.measureInWindow(node, onUIManagerMeasure); }; - if (props.force) { + if (force) { measureSelf(); } - return React.cloneElement(props.children, { ref, onLayout: measureSelf }); -}; - -MeasureElement.defaultProps = { - shouldUseTopInsets: false, + return React.cloneElement(children, { ref, onLayout: measureSelf }); };