iOS: Avoid double reload event when reloading JS
Summary: @public The bridge may send the reload event twice when reloading JS in some rare condition. The 2nd one was actually when the "new" bridge wasn't valid yet, so log an error if that happens. This may happen if the connection to Metro server gets into a weird state. Restarting Metro would solve the problem. The issue was that `RCTBridgeWillReloadNotification` fired twice for each reload with metro connected. Reviewed By: mmmulani Differential Revision: D8509448 fbshipit-source-id: 647fb98c0a97503409a10451b8f152145947ae20
This commit is contained in:
parent
73c4df219a
commit
7b9b1559a7
|
@ -876,6 +876,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
|
||||
- (void)reload
|
||||
{
|
||||
if (!_valid) {
|
||||
RCTLogError(@"Attempting to reload bridge before it's valid: %@. Try restarting the development server if connected.", self);
|
||||
}
|
||||
[_parentBridge reload];
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,11 @@ using namespace facebook::react;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (void)schedulerDidComputeMutationInstructions:(facebook::react::TreeMutationInstructionList)instructions rootTag:(ReactTag)rootTag
|
||||
{
|
||||
[_mountingManager mutateComponentViewTreeWithMutationInstructions:instructions
|
||||
|
|
|
@ -90,6 +90,8 @@
|
|||
|
||||
- (void)dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
|
||||
[self _stop];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue