Skip to content

Commit

Permalink
Fix ref type for Native Scroll View
Browse files Browse the repository at this point in the history
Summary: These types were wrong, this is a HostComponent, not a ReactNative.NativeComponent

Reviewed By: lunaleaps

Differential Revision: D17862305

fbshipit-source-id: e1e7acc7a5892f124b07cdc39d73d6ce7d414063
  • Loading branch information
elicwhite authored and facebook-github-bot committed Oct 11, 2019
1 parent fa1c2be commit db662af
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions Libraries/Components/ScrollView/ScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import type {
ScrollEvent,
LayoutEvent,
} from '../../Types/CoreEventTypes';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {State as ScrollResponderState} from '../ScrollResponder';
import type {ViewProps} from '../View/ViewPropTypes';
import type {Props as ScrollViewStickyHeaderProps} from './ScrollViewStickyHeader';
Expand Down Expand Up @@ -792,15 +793,11 @@ class ScrollView extends React.Component<Props, State> {
return ReactNative.findNodeHandle(this._innerViewRef);
}

getInnerViewRef(): ?React.ElementRef<
Class<ReactNative.NativeComponent<mixed>>,
> {
getInnerViewRef(): ?React.ElementRef<HostComponent<mixed>> {
return this._innerViewRef;
}

getNativeScrollRef(): ?React.ElementRef<
Class<ReactNative.NativeComponent<mixed>>,
> {
getNativeScrollRef(): ?React.ElementRef<HostComponent<mixed>> {
return this._scrollViewRef;
}
Expand Down Expand Up @@ -966,21 +963,13 @@ class ScrollView extends React.Component<Props, State> {
this.props.onContentSizeChange(width, height);
};

_scrollViewRef: ?React.ElementRef<
Class<ReactNative.NativeComponent<mixed>>,
> = null;
_setScrollViewRef = (
ref: ?React.ElementRef<Class<ReactNative.NativeComponent<mixed>>>,
) => {
_scrollViewRef: ?React.ElementRef<HostComponent<mixed>> = null;
_setScrollViewRef = (ref: ?React.ElementRef<HostComponent<mixed>>) => {
this._scrollViewRef = ref;
};

_innerViewRef: ?React.ElementRef<
Class<ReactNative.NativeComponent<mixed>>,
> = null;
_setInnerViewRef = (
ref: ?React.ElementRef<Class<ReactNative.NativeComponent<mixed>>>,
) => {
_innerViewRef: ?React.ElementRef<HostComponent<mixed>> = null;
_setInnerViewRef = (ref: ?React.ElementRef<HostComponent<mixed>>) => {
this._innerViewRef = ref;
};

Expand Down Expand Up @@ -1083,7 +1072,6 @@ class ScrollView extends React.Component<Props, State> {
const contentContainer = (
<ScrollContentContainerViewClass
{...contentSizeChangeProps}
// $FlowFixMe Invalid prop usage
ref={this._setInnerViewRef}
style={contentContainerStyle}
removeClippedSubviews={
Expand Down Expand Up @@ -1190,7 +1178,6 @@ class ScrollView extends React.Component<Props, State> {
// On iOS the RefreshControl is a child of the ScrollView.
// tvOS lacks native support for RefreshControl, so don't include it in that case
return (
// $FlowFixMe
<ScrollViewClass {...props} ref={this._setScrollViewRef}>
{Platform.isTV ? null : refreshControl}
{contentContainer}
Expand All @@ -1209,15 +1196,13 @@ class ScrollView extends React.Component<Props, State> {
<ScrollViewClass
{...props}
style={[baseStyle, inner]}
// $FlowFixMe
ref={this._setScrollViewRef}>
{contentContainer}
</ScrollViewClass>,
);
}
}
return (
// $FlowFixMe
<ScrollViewClass {...props} ref={this._setScrollViewRef}>
{contentContainer}
</ScrollViewClass>
Expand Down

0 comments on commit db662af

Please sign in to comment.