Skip to content

Commit a15960d

Browse files
authored
feat(iOS, SafeAreaView): use synchronous state updates (#3335)
## Description Adds support for synchronous state updates for `SafeAreaView` on iOS for RN 0.82+. | before | after | | --- | --- | | <video src="https://github.com/user-attachments/assets/68cd55ec-9845-40b0-b989-f68b9d840503" /> | <video src="https://github.com/user-attachments/assets/e4ad13d5-076c-40df-bda3-9b74feb831a6" /> ## Changes - add `immediate` flag to `updateState` ## Test code and steps to reproduce Run `TestBottomTabs`. Switch between `Tab1` and `Tab2`. ## Checklist - [x] Included code example that can be used to test this change - [x] Ensured that CI passes
1 parent 6f3697f commit a15960d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

ios/safe-area/RNSSafeAreaViewComponentView.mm

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#import "RNSSafeAreaViewNotifications.h"
99

1010
#if RCT_NEW_ARCH_ENABLED
11+
#include <cxxreact/ReactNativeVersion.h>
1112
#import <react/renderer/components/rnscreens/ComponentDescriptors.h>
1213
#import <react/renderer/components/rnscreens/Props.h>
1314
#import <rnscreens/RNSSafeAreaViewComponentDescriptor.h>
@@ -147,7 +148,13 @@ - (void)updateState
147148
}
148149

149150
auto newData = facebook::react::RNSSafeAreaViewState{RCTEdgeInsetsFromUIEdgeInsets(_currentSafeAreaInsets)};
150-
_state->updateState(std::move(newData));
151+
_state->updateState(
152+
std::move(newData)
153+
#if REACT_NATIVE_VERSION_MINOR >= 82
154+
,
155+
facebook::react::EventQueue::UpdateMode::unstable_Immediate
156+
#endif // REACT_NATIVE_VERSION_MINOR >= 82
157+
);
151158
}
152159
#else
153160
- (void)updateLocalData

0 commit comments

Comments
 (0)