Skip to content
This repository was archived by the owner on Aug 13, 2024. It is now read-only.

Commit ee946ab

Browse files
committed
fix: should require NativeComponent only on android
1 parent ac569c9 commit ee946ab

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/native.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { Platform, requireNativeComponent, UIManager } from 'react-native';
2+
import { Platform, requireNativeComponent, UIManager, View } from 'react-native';
33

44
import type { ScrollViewEnhancerProps } from './types';
55
import { warningOnHorizontalScroll } from './utils';
@@ -11,14 +11,19 @@ const LINKING_ERROR =
1111
'- You are not using Expo Go\n';
1212

1313
const ComponentName = 'ScrollViewEnhancerView';
14-
export const NativeView =
15-
UIManager.getViewManagerConfig(ComponentName) != null
16-
? requireNativeComponent<ScrollViewEnhancerProps>(ComponentName)
17-
: () => {
18-
throw new Error(LINKING_ERROR);
19-
};
14+
export const NativeView = (() => {
15+
if (Platform.OS === 'android') {
16+
return UIManager.getViewManagerConfig(ComponentName) != null
17+
? requireNativeComponent<ScrollViewEnhancerProps>(ComponentName)
18+
: () => {
19+
throw new Error(LINKING_ERROR);
20+
};
21+
} else {
22+
return View;
23+
}
24+
})();
2025

2126
export const ScrollViewEnhancerView = (props: ScrollViewEnhancerProps) => {
22-
if (__DEV__) warningOnHorizontalScroll(props);
27+
if (__DEV__ && Platform.OS === 'android') warningOnHorizontalScroll(props);
2328
return <NativeView {...props} />;
2429
};

0 commit comments

Comments
 (0)