From 6012e94e502471a429d3fac1f88a1aa2507c5f20 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Tue, 4 Jun 2013 14:36:16 -0700 Subject: [PATCH] Make unmountAndReleaseReactRootNode not throw When there isn't any React node in the DOM, unmountAndReleaseReactRootNode threw an exception because component was undefined. Instead, return whether we were able to unmount the component. --- src/core/ReactMount.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/ReactMount.js b/src/core/ReactMount.js index 600d720da8..e07e209be7 100644 --- a/src/core/ReactMount.js +++ b/src/core/ReactMount.js @@ -196,10 +196,14 @@ var ReactMount = { unmountAndReleaseReactRootNode: function(container) { var reactRootID = getReactRootID(container); var component = instanceByReactRootID[reactRootID]; - // TODO: Consider throwing if no `component` was found. - component.unmountComponentFromNode(container); - delete instanceByReactRootID[reactRootID]; - delete containersByReactRootID[reactRootID]; + if (component) { + component.unmountComponentFromNode(container); + delete instanceByReactRootID[reactRootID]; + delete containersByReactRootID[reactRootID]; + return true; + } else { + return false; + } }, /**