Skip to content

Commit 4ecde60

Browse files
authored
Fix CellRendererComponent to not error when no onLayout provided (#358)
1 parent 3881e30 commit 4ecde60

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/CellRendererComponent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ type Props<T> = {
2525
item: T;
2626
index: number;
2727
children: React.ReactNode;
28-
onLayout: (e: LayoutChangeEvent) => void;
28+
onLayout?: (e: LayoutChangeEvent) => void;
2929
style?: StyleProp<ViewStyle>;
3030
};
3131

@@ -129,7 +129,7 @@ function CellRendererComponent<T>(props: Props<T>) {
129129
const onCellLayout = useCallback(
130130
(e: LayoutChangeEvent) => {
131131
updateCellMeasurements();
132-
onLayout(e);
132+
if (onLayout) onLayout(e);
133133
},
134134
[updateCellMeasurements, onLayout]
135135
);

0 commit comments

Comments
 (0)