react-native-macos/Libraries
Kacie Bawiec d2f314af75 Make ScrollView use ForwardRef
Summary:
Have ScrollView use forwardRef so that the host component methods like `measure` and `measureLayout` are available without having to call `getNativeScrollRef`. Instead, you can use `<ScrollView ref={myRef} />` and directly call all methods of ScrollView and host components on `myRef`.

Previous usage:
```
const myRef = React.createRef<React.ElementRef<typeof ScrollView>>();
<ScrollView ref={myRef} />

const innerViewRef = myRef.current.getNativeScrollRef();

innerViewRef.measure();
```
New usage:
```
const myRef = React.createRef<React.ElementRef<typeof View>>();
<ScrollView ref={myRef} />

// now, myRef.current can be used directly as the ref
myRef.current.measure();
myRef.current.measureLayout();

// Additionally, myRef still has access to ScrollView methods
myRef.current.scrollTo(...);
```

Changes:

* Added deprecation warnings to ScrollView methods `getNativeScrollRef`, `getScrollableNode`, and `getScrollResponder`
* Added the forwardRef call to create `ForwardedScrollView` - this takes in `ref` and passes it into the class ScrollView as `scrollViewRef`.
* Forwarded the ref to the native scroll view using `setAndForwardRef`.
* Added statics onto `ForwardedScrollView` so that `ScrollView.Context` can still be accessed.
* Added type `ScrollViewImperativeMethods`, which lists the public methods of ScrollView.
* Converted all public methods of ScrollView to arrow functions. This is because they need to be bound to the forwarded ref.
* Bound all public methods of ScrollView to the forwarded ref in the `setAndForwardRef` call.
* Flow typed the final output (ForwardedScrollView) as an abstract component that takes in the props of the `ScrollView` class, and has all methods of both the inner host component (`measure`, `measureLayout`, etc) and the public methods (`scrollTo`, etc).

Changes to mockScrollView:
* Changed mockScrollView to be able to mock the function component instead of a class component
* Updated necessary tests

Changelog:
[General] [Changed] - Make ScrollView use forwardRef

Reviewed By: TheSavior

Differential Revision: D19304480

fbshipit-source-id: 6c359897526d9d5ac6bc6ab6d5f9d82bfc0d8af4
2020-03-26 16:53:46 -07:00
..
ART PlatformColor implementations for iOS and Android (#27908) 2020-03-02 15:12:09 -08:00
ActionSheetIOS Back out "Moving towards UIWindowScene support" 2020-03-05 15:58:44 -08:00
Alert Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Animated Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
AppState Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
BatchedBridge Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Blob Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
BugReporting Convert easy files to flow strict-local 2019-12-05 16:06:46 -08:00
CameraRoll Add a perfLogger argument to getTurboModuleWithJSInvoker: 2020-03-18 11:01:15 -07:00
Components Make ScrollView use ForwardRef 2020-03-26 16:53:46 -07:00
Core Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
DeprecatedPropTypes Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
EventEmitter Exact-by-default codemod for react-native-github 2019-11-21 09:42:57 -08:00
FBLazyVector make RN infra labels public 2020-02-28 12:46:49 -08:00
FBReactNativeSpec Replace fbsource// with // in xplat/js/ files [1] 2020-03-25 21:55:47 -07:00
HeapCapture Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Image Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Inspector Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Interaction Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
JSInspector Exact-by-default codemod for react-native-github 2019-11-21 09:42:57 -08:00
LayoutAnimation Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Linking Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
LinkingIOS Add a perfLogger argument to getTurboModuleWithJSInvoker: 2020-03-18 11:01:15 -07:00
Lists Make ScrollView use ForwardRef 2020-03-26 16:53:46 -07:00
LogBox Make ScrollView use ForwardRef 2020-03-26 16:53:46 -07:00
Modal Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
NativeAnimation Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
NativeModules/specs Add missing NativeEventListener methods to NativeDevSettings (#27838) 2020-01-23 13:20:53 -08:00
Network Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
NewAppScreen Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
Performance Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
PermissionsAndroid Updating the URLs to point at new domain name reactnative.dev 2020-02-24 13:09:11 -08:00
Pressability Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
PushNotificationIOS Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
RCTRequired make RN infra labels public 2020-02-28 12:46:49 -08:00
ReactNative Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
ReactPrivate Do not explicitly include ".js" in Library imports (#28311) 2020-03-17 02:11:53 -07:00
Renderer Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Settings Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Share Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Storage Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
StyleSheet Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
SurfaceBackedComponent Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
SurfaceHostingComponent Tidy up license headers [2/n] 2019-10-16 10:06:34 -07:00
Text Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
TurboModule chore: fix typo in comments (#28269) 2020-03-09 15:37:33 -07:00
TypeSafety Guard against null values in object parameters for bridged methods 2020-03-23 17:21:00 -07:00
Types Convert easy files to flow strict-local 2019-12-05 16:06:46 -08:00
Utilities Flow type infoLog 2020-03-25 21:50:12 -07:00
Vibration Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
WebSocket Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
Wrapper Back out "Rename measure to measureContent and pass it LayoutContext" 2020-03-04 05:01:53 -08:00
YellowBox Delete YellowBox 2020-02-21 10:34:40 -08:00
__flowtests__ Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
polyfills Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
vendor Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
.npmignore
Promise.js Back out "Upgrade Prettier from 1.17 to 2.0.2." 2020-03-24 21:47:35 -07:00
UTFSequence.js Clean-up $TEMPORARY$object in xplat/js/react-native-github 2019-08-21 09:58:24 -07:00
promiseRejectionIsError.js