Fix "findNodeHandle inside its render()" False Positive Warning (#29627)
This was missed in https://github.com/facebook/react/pull/29038 when unifying the "owner" abstractions, causing `findNodeHandle` to warn even outside of `render()` invocations.
Timothy Yung committed
May 28, 2024 at 20:36 UTC
3b29ed16386c1afb2e76c3db0d576184154ec141
1 file changed
+1
-1
packages/react-native-renderer/src/ReactNativePublicCompat.js
+1
-1
@@ -90,7 +90,7 @@ export function findHostInstance_DEPRECATED<TElementType: ElementType>(
90
export function findNodeHandle(componentOrHandle: any): ?number {
91
if (__DEV__) {
92
const owner = currentOwner;
93
- if (owner !== null && owner.stateNode !== null) {
93
+ if (owner !== null && isRendering && owner.stateNode !== null) {
94
if (!owner.stateNode._warnedAboutRefsInRender) {
95
console.error(
96
'%s is accessing findNodeHandle inside its render(). ' +