[@types/react-native] Add setNativeProps to ScrollView (#46242)

* Add setNativeProps to ScrollView

* Update setNativeProps type and doc

* Add test for ScrollView's setNativeProps

* Add test for View.setNativeProps
This commit is contained in:
Abílio Costa 2020-08-12 14:05:42 +01:00 committed by GitHub
parent c45d5b3a96
commit 9f8ff98dd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View File

@ -352,9 +352,9 @@ export interface NativeMethods {
* This function sends props straight to native. They will not participate in
* future diff process - this means that if you do not include them in the
* next render, they will remain active (see [Direct
* Manipulation](docs/direct-manipulation.html)).
* Manipulation](https://reactnative.dev/docs/direct-manipulation)).
*/
setNativeProps(nativeProps: Object): void;
setNativeProps(nativeProps: object): void;
/**
* Requests focus for the given input or view. The exact behavior triggered
@ -6810,6 +6810,14 @@ export class ScrollView extends ScrollViewBase {
* @deprecated Use scrollTo instead
*/
scrollWithoutAnimationTo?: (y: number, x: number) => void;
/**
* This function sends props straight to native. They will not participate in
* future diff process - this means that if you do not include them in the
* next render, they will remain active (see [Direct
* Manipulation](https://reactnative.dev/docs/direct-manipulation)).
*/
setNativeProps(nativeProps: object): void;
}
export interface NativeScrollRectangle {

View File

@ -310,10 +310,9 @@ class Welcome extends React.Component<ElementProps<View> & { color: string }> {
};
testNativeMethods() {
// this.setNativeProps({});
const { rootView } = this.refs;
rootView.setNativeProps({});
rootView.measure((x: number, y: number, width: number, height: number) => {});
}
@ -597,6 +596,12 @@ class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListVi
console.log(event);
};
scrollView: ScrollView | null = null;
testNativeMethods() {
this.scrollView && this.scrollView.setNativeProps({ scrollEnabled: false });
}
render() {
const scrollViewStyle1 = StyleSheet.create({
scrollView: {
@ -616,6 +621,7 @@ class ScrollerListComponentTest extends React.Component<{}, { dataSource: ListVi
return (
<ScrollView
ref={ref => (this.scrollView = ref)}
horizontal={true}
nestedScrollEnabled={true}
invertStickyHeaders={true}