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:
cailenmusselman
2017-03-30 14:15:34 -07:00
committed by Andy
parent 6a285d2dcf
commit 389adfc542
2 changed files with 32 additions and 7 deletions
+1 -1
View File
@@ -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;
+31 -6
View File
@@ -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>
)
}