findNodeHandle() — react Function Reference
Architecture documentation for the findNodeHandle() function in ReactNativePublicCompat.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD a3dc8ce3_5fa4_00f6_cc2f_856df9b1b09d["findNodeHandle()"] c8cde18a_a62b_2ad5_9e88_a5d655a07f02["ReactNativePublicCompat.js"] a3dc8ce3_5fa4_00f6_cc2f_856df9b1b09d -->|defined in| c8cde18a_a62b_2ad5_9e88_a5d655a07f02 504aef00_0513_3316_fb99_9e268f03e589["getHostNode()"] 504aef00_0513_3316_fb99_9e268f03e589 -->|calls| a3dc8ce3_5fa4_00f6_cc2f_856df9b1b09d style a3dc8ce3_5fa4_00f6_cc2f_856df9b1b09d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-native-renderer/src/ReactNativePublicCompat.js lines 91–160
export function findNodeHandle(componentOrHandle: any): ?number {
if (__DEV__) {
const owner = currentOwner;
if (owner !== null && isRendering && owner.stateNode !== null) {
if (!owner.stateNode._warnedAboutRefsInRender) {
console.error(
'%s is accessing findNodeHandle inside its render(). ' +
'render() should be a pure function of props and state. It should ' +
'never access something that requires stale data from the previous ' +
'render, such as refs. Move this logic to componentDidMount and ' +
'componentDidUpdate instead.',
getComponentNameFromType(owner.type) || 'A component',
);
}
owner.stateNode._warnedAboutRefsInRender = true;
}
}
if (componentOrHandle == null) {
return null;
}
if (typeof componentOrHandle === 'number') {
// Already a node handle
return componentOrHandle;
}
// For compatibility with legacy renderer instances
if (componentOrHandle._nativeTag) {
return componentOrHandle._nativeTag;
}
// For compatibility with Fabric instances
if (
componentOrHandle.canonical != null &&
componentOrHandle.canonical.nativeTag != null
) {
return componentOrHandle.canonical.nativeTag;
}
// For compatibility with Fabric public instances
const nativeTag = getNativeTagFromPublicInstance(componentOrHandle);
if (nativeTag) {
return nativeTag;
}
let hostInstance;
if (__DEV__) {
hostInstance = findHostInstanceWithWarning(
componentOrHandle,
'findNodeHandle',
);
} else {
hostInstance = findHostInstance(componentOrHandle);
}
if (hostInstance == null) {
// $FlowFixMe[incompatible-return] Flow limitation in refining an opaque type
return hostInstance;
}
if (hostInstance._nativeTag != null) {
// $FlowFixMe[incompatible-return] For compatibility with legacy renderer instances
return hostInstance._nativeTag;
}
// $FlowFixMe[incompatible-call] Necessary when running Flow on the legacy renderer
return getNativeTagFromPublicInstance(hostInstance);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does findNodeHandle() do?
findNodeHandle() is a function in the react codebase, defined in packages/react-native-renderer/src/ReactNativePublicCompat.js.
Where is findNodeHandle() defined?
findNodeHandle() is defined in packages/react-native-renderer/src/ReactNativePublicCompat.js at line 91.
What calls findNodeHandle()?
findNodeHandle() is called by 1 function(s): getHostNode.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free