Skip to content

Commit ae60caa

Browse files
JoshuaGrossgaearon
andauthored
[Fabric] Fix targetAsInstance dispatchEvent "cannot read property of null" (#18156)
* Fix Fabric targetAsInstance dispatchEvent: targetFiber stateNode is null in some cases Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
1 parent d72700f commit ae60caa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/react-native-renderer/src/ReactFabricEventEmitter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ export function dispatchEvent(
8787
let eventTarget = null;
8888
if (enableNativeTargetAsInstance) {
8989
if (targetFiber != null) {
90-
eventTarget = targetFiber.stateNode.canonical;
90+
const stateNode = targetFiber.stateNode;
91+
// Guard against Fiber being unmounted
92+
if (stateNode != null) {
93+
eventTarget = stateNode.canonical;
94+
}
9195
}
9296
} else {
9397
eventTarget = nativeEvent.target;

0 commit comments

Comments
 (0)