Skip to content

Commit

Permalink
Remove invalidate observer instead of re-adding observer in DeviceInf…
Browse files Browse the repository at this point in the history
…o module (facebook#43737)

Summary:
Previous fix brings in facebook#42396. Seems it's a mistake to re-add observer?
So let's remove it and also not `invalidate` method not be called twice.

[IOS] [FIXED] - Remove invalidate observer instead of re-adding observer in DeviceInfo module

Pull Request resolved: facebook#43737

Test Plan: Fix for facebook#42120 also works.

Reviewed By: javache

Differential Revision: D55692219

Pulled By: cipolleschi

fbshipit-source-id: dba1ddc39a9f2611fc2b84fadf8c23827891379a
  • Loading branch information
zhongwuzw authored and Saadnajmi committed May 24, 2024
1 parent 888fb60 commit 24e4667
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/react-native/React/CoreModules/RCTDeviceInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ - (void)initialize

- (void)invalidate
{
if (_invalidated) {
return;
}
_invalidated = YES;
[self _cleanupObservers];
}
Expand All @@ -118,10 +121,7 @@ - (void)_cleanupObservers

[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTWindowFrameDidChangeNotification object:nil];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(invalidate)
name:RCTBridgeWillInvalidateModulesNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillInvalidateModulesNotification object:nil];
}

static BOOL RCTIsIPhoneNotched()
Expand Down

0 comments on commit 24e4667

Please sign in to comment.