Skip to content

Commit d19515f

Browse files
Fix issue in measure component (#5)
1 parent 19b87d5 commit d19515f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/components/devsupport/components/measure/measure.component.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export const MeasureElement: React.FC<MeasureElementProps> = (props): MeasuringE
5656
const boundFrame: Frame = new Frame(
5757
frame.origin.x - window.size.width,
5858
frame.origin.y,
59-
frame.size.width,
60-
frame.size.height,
59+
Math.floor(frame.size.width),
60+
Math.floor(frame.size.height),
6161
);
6262

6363
return bindToWindow(boundFrame, window);
@@ -68,14 +68,16 @@ export const MeasureElement: React.FC<MeasureElementProps> = (props): MeasuringE
6868
measureSelf();
6969
} else {
7070
const originY = props.shouldUseTopInsets ? y + StatusBar.currentHeight || 0 : y;
71-
const frame: Frame = bindToWindow(new Frame(x, originY, w, h), Frame.window());
71+
const frame: Frame = bindToWindow(new Frame(x, originY, Math.floor(w), Math.floor(h)), Frame.window());
7272
props.onMeasure(frame);
7373
}
7474
};
7575

7676
const measureSelf = (): void => {
7777
const node: number = findNodeHandle(ref.current);
78-
UIManager.measureInWindow(node, onUIManagerMeasure);
78+
if (node) {
79+
UIManager.measureInWindow(node, onUIManagerMeasure);
80+
}
7981
};
8082

8183
if (props.force) {
@@ -84,7 +86,3 @@ export const MeasureElement: React.FC<MeasureElementProps> = (props): MeasuringE
8486

8587
return React.cloneElement(props.children, { ref, onLayout: measureSelf });
8688
};
87-
88-
MeasureElement.defaultProps = {
89-
shouldUseTopInsets: false,
90-
};

0 commit comments

Comments
 (0)