From 48eea39ffa81deec584f2b1ae8e168f1fdf1eef1 Mon Sep 17 00:00:00 2001 From: heecheolman Date: Wed, 9 Sep 2026 12:18:19 +0900 Subject: [PATCH] Fix TypeError in Fabric getListener when event target stateNode is undefined getListener guards the fiber's stateNode with a strict null check: inst = inst.stateNode; if (null === inst) return null; Within the reconciler this is sufficient (stateNode is initialized to null and reset to null on detach), but the responder event path receives its target from native dispatch. When the instance handle delivered across the JSI boundary is no longer a live host fiber (e.g. a touch delivered after the view unmounted), reading .stateNode yields undefined, which passes the strict check and crashes in getFiberCurrentPropsFromNode with "Cannot read property 'canonical' of undefined". Loosen the check to `null == inst`, matching the surrounding event-plugin guards (`null != target`, `null == targetInst`), so the event is dropped for a dead target instead of throwing. Note: ReactFabric-* bundles are generated from facebook/react; the source counterpart is packages/react-native-renderer/src/ReactNativeGetListener.js (and its inlined copy in the responder plugin). Co-Authored-By: Claude Fable 5 --- .../Libraries/Renderer/implementations/ReactFabric-dev.js | 4 ++-- .../Libraries/Renderer/implementations/ReactFabric-prod.js | 4 ++-- .../Renderer/implementations/ReactFabric-profiling.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js index daab0e35a8e5..46b94646eb34 100644 --- a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js +++ b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-dev.js @@ -996,7 +996,7 @@ __DEV__ && } function getListener1ドル(inst, registrationName) { inst = inst.stateNode; - if (null === inst) return null; + if (null == inst) return null; inst = getFiberCurrentPropsFromNode1ドル(inst); if (null === inst) return null; if ((inst = inst[registrationName]) && "function" !== typeof inst) @@ -1136,7 +1136,7 @@ __DEV__ && } function getListener(inst, registrationName) { inst = inst.stateNode; - if (null === inst) return null; + if (null == inst) return null; inst = getFiberCurrentPropsFromNode1ドル(inst); if (null === inst) return null; if ((inst = inst[registrationName]) && "function" !== typeof inst) diff --git a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js index 2625bf690ab0..a1b882192833 100644 --- a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js +++ b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-prod.js @@ -672,7 +672,7 @@ function traverseTwoPhase1ドル(inst, fn, arg) { } function getListener1ドル(inst, registrationName) { inst = inst.stateNode; - if (null === inst) return null; + if (null == inst) return null; inst = getFiberCurrentPropsFromNode1ドル(inst); if (null === inst) return null; if ((inst = inst[registrationName]) && "function" !== typeof inst) @@ -1086,7 +1086,7 @@ var plugins = [], registrationNameModules = {}; function getListener(inst, registrationName) { inst = inst.stateNode; - if (null === inst) return null; + if (null == inst) return null; inst = getFiberCurrentPropsFromNode1ドル(inst); if (null === inst) return null; if ((inst = inst[registrationName]) && "function" !== typeof inst) diff --git a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js index 544c75406ef2..79e16caa3835 100644 --- a/packages/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js +++ b/packages/react-native/Libraries/Renderer/implementations/ReactFabric-profiling.js @@ -737,7 +737,7 @@ function traverseTwoPhase1ドル(inst, fn, arg) { } function getListener1ドル(inst, registrationName) { inst = inst.stateNode; - if (null === inst) return null; + if (null == inst) return null; inst = getFiberCurrentPropsFromNode1ドル(inst); if (null === inst) return null; if ((inst = inst[registrationName]) && "function" !== typeof inst) @@ -1151,7 +1151,7 @@ var plugins = [], registrationNameModules = {}; function getListener(inst, registrationName) { inst = inst.stateNode; - if (null === inst) return null; + if (null == inst) return null; inst = getFiberCurrentPropsFromNode1ドル(inst); if (null === inst) return null; if ((inst = inst[registrationName]) && "function" !== typeof inst)

AltStyle によって変換されたページ (->オリジナル) /