From 60f381a8b9094e7dfaf01bea1b745d576cc458f6 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 17 Feb 2023 14:50:53 -0800 Subject: [PATCH] Fix a crash when reloading the JS bundle Summary: changelog: [iOS][Fixed] Fix a crash when reloading JS bundle Do not crash if self is nil. Reviewed By: blakef Differential Revision: D43352039 fbshipit-source-id: dd53677ca152d4021e43ed8d0f1b51c071ca3365 --- React/CoreModules/RCTDevSplitBundleLoader.mm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/React/CoreModules/RCTDevSplitBundleLoader.mm b/React/CoreModules/RCTDevSplitBundleLoader.mm index 8eb756db0e0232..9dd1b0ebd3ebf2 100644 --- a/React/CoreModules/RCTDevSplitBundleLoader.mm +++ b/React/CoreModules/RCTDevSplitBundleLoader.mm @@ -63,10 +63,12 @@ + (BOOL)requiresMainQueueSetup return; } __typeof(self) strongSelf = weakSelf; - strongSelf->_loadScript(source); - RCTDevSettings *devSettings = [strongSelf->_moduleRegistry moduleForName:"RCTDevSettings"]; - [devSettings setupHMRClientWithAdditionalBundleURL:source.url]; - resolve(@YES); + if (strongSelf) { + strongSelf->_loadScript(source); + RCTDevSettings *devSettings = [strongSelf->_moduleRegistry moduleForName:"RCTDevSettings"]; + [devSettings setupHMRClientWithAdditionalBundleURL:source.url]; + resolve(@YES); + } }]; } }