mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 12:30:18 +00:00
findNodeHandle also accepts base react-native components (#15444)
* findNodeHandle also accepts base react-native components We're also able to pass in base react-native components like View, TextView, etc. to findNodeHandle * Added static tests for findNodeHandle definition * Removed trailing whitespace * Okay NOW all trailing white-space is removed
This commit is contained in:
Vendored
+1
-1
@@ -8418,7 +8418,7 @@ export function requireNativeComponent<P>(
|
||||
extraConfig?: {nativeOnly?: any}
|
||||
): React.ComponentClass<P>;
|
||||
|
||||
export function findNodeHandle(componentOrHandle: null | number | React.Component<any, any>): null | number;
|
||||
export function findNodeHandle(componentOrHandle: null | number | React.Component<any, any> | React.ComponentClass<any>): null | number;
|
||||
|
||||
export function processColor(color: any): number;
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
View,
|
||||
ViewStyle,
|
||||
ViewPagerAndroid,
|
||||
findNodeHandle
|
||||
} from 'react-native';
|
||||
|
||||
function testDimensions() {
|
||||
@@ -88,20 +89,43 @@ const stylesAlt = StyleSheet.create(
|
||||
}
|
||||
)
|
||||
|
||||
class CustomView extends React.Component<{}, {}> {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Text>Custom View</Text>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Welcome extends React.Component<any, any> {
|
||||
refs: {
|
||||
[key: string]: any
|
||||
rootView: View
|
||||
[key: string]: any
|
||||
rootView: View
|
||||
customView: CustomView
|
||||
}
|
||||
|
||||
testNativeMethods() {
|
||||
// this.setNativeProps({});
|
||||
// this.setNativeProps({});
|
||||
|
||||
const { rootView } = this.refs;
|
||||
const { rootView } = this.refs;
|
||||
|
||||
rootView.measure((x: number, y: number, width: number, height: number) => {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
testFindNodeHandle() {
|
||||
|
||||
const { rootView, customView } = this.refs;
|
||||
|
||||
let nativeComponentHandle = findNodeHandle(rootView);
|
||||
|
||||
let customComponentHandle = findNodeHandle(customView);
|
||||
|
||||
let fromHandle = findNodeHandle(customComponentHandle);
|
||||
|
||||
rootView.measure((x: number, y: number, width: number, height: number) => {
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -117,6 +141,7 @@ class Welcome extends React.Component<any, any> {
|
||||
Press Cmd+R to reload,{'\n'}
|
||||
Cmd+D or shake for dev menu
|
||||
</Text>
|
||||
<CustomView ref="customView" />
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user