Skip to content

Commit 396f941

Browse files
authored
fix(ios): prevent unnecessary map view style changes on prop update (#4014)
1 parent 72db6ae commit 396f941

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ios/RNMBX/RNMBXMapViewComponentView.mm

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ @implementation RNMBXMapViewComponentView {
5050
RNMBXMapView *_view;
5151
RNMBXMapViewEventDispatcher *_eventDispatcher;
5252
CGRect _frame;
53+
id _lastStyleURL;
5354
}
5455

5556
- (instancetype)initWithFrame:(CGRect)frame
@@ -135,7 +136,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
135136
{
136137
const auto &oldViewProps = static_cast<const RNMBXMapViewProps &>(*oldProps);
137138
const auto &newViewProps = static_cast<const RNMBXMapViewProps &>(*props);
138-
139+
139140
RNMBX_REMAP_OPTIONAL_PROP_BOOL(attributionEnabled, reactAttributionEnabled)
140141

141142
id attributionPosition = RNMBXConvertFollyDynamicToId(newViewProps.attributionPosition);
@@ -187,7 +188,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
187188
RNMBX_REMAP_OPTIONAL_PROP_BOOL(scrollEnabled, reactScrollEnabled)
188189

189190
RNMBX_REMAP_OPTIONAL_PROP_BOOL(rotateEnabled, reactRotateEnabled)
190-
191+
191192
RNMBX_REMAP_OPTIONAL_PROP_BOOL(pitchEnabled, reactPitchEnabled)
192193

193194
id preferredFramesPerSecond = RNMBXConvertFollyDynamicToId(newViewProps.preferredFramesPerSecond);
@@ -209,7 +210,10 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &
209210

210211
id styleURL = RNMBXConvertFollyDynamicToId(newViewProps.styleURL);
211212
if (styleURL != nil) {
212-
_view.reactStyleURL = styleURL;
213+
if (_lastStyleURL == nil || ![_lastStyleURL isEqual:styleURL]) {
214+
_view.reactStyleURL = styleURL;
215+
_lastStyleURL = styleURL;
216+
}
213217
}
214218

215219
[super updateProps:props oldProps:oldProps];

0 commit comments

Comments
 (0)