From 7615d74d14fb3d2e5bf8c0d02e5e39bef4565b01 Mon Sep 17 00:00:00 2001 From: James Ide Date: Thu, 24 Sep 2015 02:42:39 -0700 Subject: [PATCH] Check self.isValid in RCTBatchedBridge after initial script evaluation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: I noticed that sometimes the batched bridge would be valid before `[self enqueueApplicationScript:url:onComplete:]` but then become invalid in the completion callback. This diff checks `self.isValid` inside of the callback. Closes https://github.com/facebook/react-native/pull/2016 Reviewed By: @​trunkagent, @jspahrsummers Differential Revision: D2443438 Pulled By: @tadeuzagallo --- React/Base/RCTBatchedBridge.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index de4936002..e4b8e7828 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -340,6 +340,10 @@ RCT_EXTERN NSArray *RCTGetModuleClasses(void); sourceCodeModule.scriptText = sourceCode; [self enqueueApplicationScript:sourceCode url:self.bundleURL onComplete:^(NSError *loadError) { + if (!self.isValid) { + return; + } + if (loadError) { dispatch_async(dispatch_get_main_queue(), ^{ [self stopLoadingWithError:loadError];