Skip to content

Commit 9db3eb6

Browse files
zhongwuzwgabrieldonadel
authored andcommitted
Remove invalidate observer instead of re-adding observer in DeviceInfo 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
1 parent c7a1f24 commit 9db3eb6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

packages/react-native/React/CoreModules/RCTDeviceInfo.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ - (void)initialize
8989

9090
- (void)invalidate
9191
{
92+
if (_invalidated) {
93+
return;
94+
}
9295
_invalidated = YES;
9396
[self _cleanupObservers];
9497
}
@@ -109,10 +112,7 @@ - (void)_cleanupObservers
109112

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

112-
[[NSNotificationCenter defaultCenter] addObserver:self
113-
selector:@selector(invalidate)
114-
name:RCTBridgeWillInvalidateModulesNotification
115-
object:nil];
115+
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillInvalidateModulesNotification object:nil];
116116
}
117117

118118
static BOOL RCTIsIPhoneNotched()

0 commit comments

Comments
 (0)