diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 2ef5ddc70a..8f079036f7 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -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 { diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 1763422d8c..c3683f5ba5 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -310,10 +310,9 @@ class Welcome extends React.Component & { 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 ( (this.scrollView = ref)} horizontal={true} nestedScrollEnabled={true} invertStickyHeaders={true}