Skip to content

Commit 3bc7fc0

Browse files
zhongwuzwSaadnajmi
authored andcommitted
Remove invalidate observer instead of re-adding observer in DeviceInfo 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
1 parent 85de35b commit 3bc7fc0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

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

9999
- (void)invalidate
100100
{
101+
if (_invalidated) {
102+
return;
103+
}
101104
_invalidated = YES;
102105
[self _cleanupObservers];
103106
}
@@ -118,10 +121,7 @@ - (void)_cleanupObservers
118121

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

121-
[[NSNotificationCenter defaultCenter] addObserver:self
122-
selector:@selector(invalidate)
123-
name:RCTBridgeWillInvalidateModulesNotification
124-
object:nil];
124+
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTBridgeWillInvalidateModulesNotification object:nil];
125125
}
126126

127127
static BOOL RCTIsIPhoneNotched()

0 commit comments

Comments
 (0)