Skip to content

Commit 8d98896

Browse files
committed
feat: basic support to avoid react-native-web crash
1 parent e35c528 commit 8d98896

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/index.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
5050
avoidKeyboardLikeIOS: Platform.select({
5151
ios: true,
5252
android: false,
53+
default: true,
5354
}),
5455
modalTopOffset: Platform.select({
5556
ios: 0,
5657
android: StatusBar.currentHeight || 0,
58+
default: 0,
5759
}),
5860
panGestureEnabled: true,
5961
closeOnOverlayTap: true,

src/styles.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { StyleSheet } from 'react-native';
1+
import { StyleSheet, Dimensions } from 'react-native';
2+
3+
import { isWeb } from './utils/devices';
4+
5+
const { height } = Dimensions.get('window');
26

37
export default StyleSheet.create({
48
modalize: {
@@ -79,6 +83,8 @@ export default StyleSheet.create({
7983
bottom: 0,
8084
left: 0,
8185
zIndex: 0,
86+
87+
height: isWeb ? height : undefined,
8288
},
8389

8490
overlay__background: {

src/utils/devices.ts

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ const { width, height } = Dimensions.get('window');
55
export const isIos = Platform.OS === 'ios';
66
export const isIphoneX =
77
isIos && (height === 812 || width === 812 || height === 896 || width === 896);
8+
export const isWeb = typeof document !== 'undefined';

0 commit comments

Comments
 (0)