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 (#43737)

Summary:
Previous fix brings in #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: #43737

Test Plan: Fix for #42120 also works.

Reviewed By: javache

Differential Revision: D55692219

Pulled By: cipolleschi

fbshipit-source-id: dba1ddc39a9f2611fc2b84fadf8c23827891379a
  • Loading branch information
zhongwuzw authored and gabrieldonadel committed Jul 1, 2024
1 parent c7a1f24 commit 9db3eb6
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 @@ -89,6 +89,9 @@ - (void)initialize

- (void)invalidate
{
if (_invalidated) {
return;
}
_invalidated = YES;
[self _cleanupObservers];
}
Expand All @@ -109,10 +112,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 9db3eb6

Please sign in to comment.