Fix nodeHandle crash

Summary:
It's supposed to take a component or a handle, per the arg name, so switch on the type (and handle `null`).

`FlatListExample` no longer crashes.

Reviewed By: bvaughn, sebmarkbage

Differential Revision: D4752619

fbshipit-source-id: 720421f648f7c2049b5cc44f006484eb47d22d86
This commit is contained in:
Spencer Ahrens 2017-03-21 22:45:50 -07:00 committed by Facebook Github Bot
parent 46d6766a53
commit 93c438d470

View File

@ -37,7 +37,11 @@ var ReactNative = {
// The injected findNodeHandle() strategy returns the instance wrapper though.
// See NativeMethodsMixin#setNativeProps for more info on why this is done.
findNodeHandle(componentOrHandle : any) : ?number {
return findNodeHandle(componentOrHandle).getHostNode();
const nodeHandle = findNodeHandle(componentOrHandle);
if (nodeHandle == null || typeof nodeHandle === 'number') {
return nodeHandle;
}
return nodeHandle.getHostNode();
},
render: render,