@samitouri / QOS-React-2 / commits / 6012e94e50
Fork 0

The library for web and native user interfaces.

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.

Ben Alpert committed Jun 4, 2013 at 14:36 UTC 6012e94e502471a429d3fac1f88a1aa2507c5f20
1 file changed +8 -4
src/core/ReactMount.js
+8 -4
@@ -196,10 +196,14 @@ var ReactMount = {
196 unmountAndReleaseReactRootNode: function(container) {
197 var reactRootID = getReactRootID(container);
198 var component = instanceByReactRootID[reactRootID];
199 - // TODO: Consider throwing if no `component` was found.
200 - component.unmountComponentFromNode(container);
201 - delete instanceByReactRootID[reactRootID];
202 - delete containersByReactRootID[reactRootID];
199 + if (component) {
200 + component.unmountComponentFromNode(container);
201 + delete instanceByReactRootID[reactRootID];
202 + delete containersByReactRootID[reactRootID];
203 + return true;
204 + } else {
205 + return false;
206 + }
207 },
208
209 /**