Skip to content

Commit

Permalink
[Fabric] Fix targetAsInstance dispatchEvent "cannot read property of …
Browse files Browse the repository at this point in the history
…null" (#18156)

* Fix Fabric targetAsInstance dispatchEvent: targetFiber stateNode is null in some cases

Co-authored-by: Dan Abramov <[email protected]>
  • Loading branch information
JoshuaGross and gaearon authored Feb 28, 2020
1 parent d72700f commit ae60caa
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ export function dispatchEvent(
let eventTarget = null;
if (enableNativeTargetAsInstance) {
if (targetFiber != null) {
eventTarget = targetFiber.stateNode.canonical;
const stateNode = targetFiber.stateNode;
// Guard against Fiber being unmounted
if (stateNode != null) {
eventTarget = stateNode.canonical;
}
}
} else {
eventTarget = nativeEvent.target;
Expand Down

0 comments on commit ae60caa

Please sign in to comment.