Skip to content

Commit e65f914

Browse files
Fixed AndroidHorizontalScrollView issue
react-native 0.49.0 introduces a weird breaking change that don't allow us to use requireNativeComponent twice of the same view name, and since we are using the same implementation of ScrollView.js, we are requiring AndroidHorizontalScrollView twice, which now conflicts with the current ScrollView component and throws a error. This commit implements ReactHorizontalNestedScrollViewManager that replaces the native view name (REACT_CLASS) and extends the default behavior of the ReactHorizontalScrollViewManager.
1 parent 3d6904f commit e65f914

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

android/src/main/java/com/rnnestedscrollview/RNNestedScrollViewPackage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public List<NativeModule> createNativeModules(ReactApplicationContext reactConte
1919
@Override
2020
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
2121
return Arrays.<ViewManager>asList(
22-
new ReactNestedScrollViewManager()
22+
new ReactNestedScrollViewManager(),
23+
new ReactHorizontalNestedScrollViewManager()
2324
);
2425
}
2526
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.rnnestedscrollview;
2+
3+
import com.facebook.react.views.scroll.ReactHorizontalScrollViewManager;
4+
5+
/**
6+
* react-native@0.49.0 introduces a weird breaking change that don't allow us to use
7+
* requireNativeComponent twice of the same view name, and since we are using the same
8+
* implementation of ScrollView.js, we are requiring AndroidHorizontalScrollView twice
9+
* which now throws a error.
10+
*
11+
* This class only exists to replace the native view name (REACT_CLASS) and extends the default
12+
* behavior of the ReactHorizontalScrollViewManager.
13+
*/
14+
public class ReactHorizontalNestedScrollViewManager extends ReactHorizontalScrollViewManager {
15+
16+
protected static final String REACT_CLASS = "AndroidHorizontalNestedScrollView";
17+
18+
@Override
19+
public String getName() {
20+
return REACT_CLASS;
21+
}
22+
}

lib/NestedScrollView.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const {
1717
View,
1818
Animated,
1919
Platform,
20+
UIManager,
2021
StyleSheet,
2122
PointPropType,
2223
ViewPropTypes,
@@ -851,7 +852,7 @@ if (Platform.OS === 'android') {
851852
nativeOnlyProps
852853
);
853854
AndroidHorizontalScrollView = requireNativeComponent(
854-
'AndroidHorizontalScrollView',
855+
'AndroidHorizontalNestedScrollView',
855856
(ScrollView: ReactClass<any>),
856857
nativeOnlyProps
857858
);

0 commit comments

Comments
 (0)