Skip to content

Commit cf27368

Browse files
TomCorvuszibs
andauthored
Replace onLayout with ref to measure Canvas size (#605)
Co-authored-by: Eli Zibin <1131641+zibs@users.noreply.github.com>
1 parent 4d62681 commit cf27368

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

.changeset/poor-coins-compete.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"victory-native": patch
3+
---
4+
5+
move deprecate canvas onLayout onto parent containers

lib/src/cartesian/CartesianChart.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ function CartesianChartContent<
649649

650650
// Body of the chart.
651651
const body = (
652-
<Canvas style={{ flex: 1 }} onLayout={onLayout}>
652+
<Canvas style={{ flex: 1 }}>
653653
{YAxisComponents}
654654
{XAxisComponents}
655655
{FrameComponent}
@@ -689,7 +689,10 @@ function CartesianChartContent<
689689
}
690690

691691
return (
692-
<GestureHandlerRootView style={{ flex: 1, overflow: "hidden" }}>
692+
<GestureHandlerRootView
693+
style={{ flex: 1, overflow: "hidden" }}
694+
onLayout={onLayout}
695+
>
693696
{body}
694697
<GestureHandler
695698
config={gestureHandlerConfig}

lib/src/polar/PolarChart.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {
44
StyleSheet,
55
View,
66
type ViewStyle,
7-
type LayoutChangeEvent,
87
type StyleProp,
8+
type LayoutChangeEvent,
99
} from "react-native";
1010
import { Gesture, GestureHandlerRootView } from "react-native-gesture-handler";
1111
import { type ContextBridge, FiberProvider, useContextBridge } from "its-fine";
@@ -57,10 +57,9 @@ const PolarChartBase = (
5757
}
5858

5959
return (
60-
<View style={[styles.baseContainer, containerStyle]}>
60+
<View style={[styles.baseContainer, containerStyle]} onLayout={onLayout}>
6161
<GestureHandlerRootView style={{ flex: 1, overflow: "hidden" }}>
6262
<Canvas
63-
onLayout={onLayout}
6463
style={StyleSheet.flatten([
6564
styles.canvasContainer,
6665
hasMeasuredLayoutSize ? { width, height } : null,

0 commit comments

Comments
 (0)