Skip to content

Commit 31d1d9d

Browse files
committed
Fix flatlist bug where half of the content won't render on mobile safari (ios 15);
1 parent bfe201a commit 31d1d9d

File tree

1 file changed

+26
-3
lines changed
  • packages/react-native-web/src/vendor/react-native/VirtualizedList

1 file changed

+26
-3
lines changed

packages/react-native-web/src/vendor/react-native/VirtualizedList/index.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
12031203

12041204
_defaultRenderScrollComponent = props => {
12051205
const onRefresh = props.onRefresh;
1206+
const inversionStyle = this.props.inverted
1207+
? this.props.horizontal
1208+
? styles.rowReverse
1209+
: styles.columnReverse
1210+
: null;
1211+
12061212
if (this._isNestedWithSameOrientation()) {
12071213
// $FlowFixMe - Typing ReactNativeComponent revealed errors
12081214
return <View {...props} />;
@@ -1231,11 +1237,23 @@ class VirtualizedList extends React.PureComponent<Props, State> {
12311237
props.refreshControl
12321238
)
12331239
}
1240+
contentContainerStyle={StyleSheet.compose(
1241+
inversionStyle,
1242+
this.props.contentContainerStyle,
1243+
)}
12341244
/>
12351245
);
12361246
} else {
12371247
// $FlowFixMe Invalid prop usage
1238-
return <ScrollView {...props} />;
1248+
return (
1249+
<ScrollView
1250+
{...props}
1251+
contentContainerStyle={StyleSheet.compose(
1252+
inversionStyle,
1253+
this.props.contentContainerStyle,
1254+
)}
1255+
/>
1256+
);
12391257
}
12401258
};
12411259

@@ -1703,6 +1721,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
17031721
this._getFrameMetricsApprox,
17041722
this._scrollMetrics,
17051723
);
1724+
1725+
// revert the state if calculations are off
1726+
if (newState.first === newState.last) {
1727+
newState = state
1728+
}
17061729
}
17071730
}
17081731
} else {
@@ -2061,10 +2084,10 @@ function describeNestedLists(childList: {
20612084

20622085
const styles = StyleSheet.create({
20632086
verticallyInverted: {
2064-
flexDirection: 'column-reverse',
2087+
transform: [{scaleY: -1}],
20652088
},
20662089
horizontallyInverted: {
2067-
flexDirection: 'row-reverse',
2090+
transform: [{scaleX: -1}],
20682091
},
20692092
row: {
20702093
flexDirection: 'row',

0 commit comments

Comments
 (0)