From fd4ad6ca82676e4f63bad26eb0869981439ba106 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Wed, 22 Feb 2017 12:25:43 -0800 Subject: [PATCH] Ignore event listeners on unmounted components Summary: When a touch responder gets unmounted, it can still get events dispatched to it. We used to ignore those errors but in the new model we read the props instead of the event listener bank. The props still exist after unmount. Instead, I check that the rootNodeID is still set since this gets reset during unmount. Reviewed By: spicyj, bvaughn Differential Revision: D4597127 fbshipit-source-id: b405e4ef1bcb14970be76d9ab7203cebf1f4d6c9 --- .../src/renderers/shared/shared/event/EventPluginHub.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Libraries/Renderer/src/renderers/shared/shared/event/EventPluginHub.js b/Libraries/Renderer/src/renderers/shared/shared/event/EventPluginHub.js index a2fe2d0df..6c4235ea4 100644 --- a/Libraries/Renderer/src/renderers/shared/shared/event/EventPluginHub.js +++ b/Libraries/Renderer/src/renderers/shared/shared/event/EventPluginHub.js @@ -142,6 +142,10 @@ var EventPluginHub = { // Text node, let it bubble through. return null; } + if (!inst._rootNodeID) { + // If the instance is already unmounted, we have no listeners. + return null; + } const props = inst._currentElement.props; listener = props[registrationName]; if (shouldPreventMouseEvent(registrationName, inst._currentElement.type, props)) {