This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exception in scrollResponderScrollNativeHandleToKeyboard when ref…
… is null Summary: We are seeing these errors in prod: ``` TypeError: Cannot read property '_nativeTag' of null at ReactNativeFiberHostComponent.prototype.measureLayout(ReactNativeRenderer-prod.fb.js:1594) ScrollResponderMixin.scrollResponderScrollNativeHandleToKeyboard(ScrollResponder.js:557) ``` This error is coming from these lines: https://github.com/facebook/react-native/blob/69c38e5a639f34620038ae5724426c92c355e509/Libraries/Components/ScrollResponder.js#L563-L567 Either `nodeHandle` is null or `this.getInnerViewRef()`. If `nodeHandle` was null, we'd get an error that we can't call `measureLayout` on null. So `this.getInnerViewRef()` must be null. In the React Native Renderer this error of `_nativeTag of null` is coming from this line: https://github.com/facebook/react/blob/db8afe4f6318dba422177a2054204ef089570ad8/packages/react-native-renderer/src/ReactNativeFiberHostComponent.js#L84 Which means indeed `this.getInnerViewRef()` is null. So adding a null check here which is what we do at all the other product callsites of `measureLayout`. Flow should have caught this, but because ScrollView is one of the only components left using mixins (ScrollResponder), `this.getInnerViewRef` is typed as `any` instead of what it should be: ``` ?React.ElementRef<Class<ReactNative.NativeComponent<mixed>>> ``` If `scrollResponder` was typed correctly then Flow would have caught this. Changelog: [Fixed] Exception in scrollResponderScrollNativeHandleToKeyboard when ref is null Reviewed By: mmmulani Differential Revision: D17717150 fbshipit-source-id: d7bc4c897ad259fb588e8100f37ccfb8a5d07874
- Loading branch information
Showing 1 changed file with 7 additions and 1 deletion.