From 1f4535c17572df78e2a033890220337e5703b614 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Mon, 16 Mar 2020 02:40:35 -0700 Subject: [PATCH] Fix state.padding being out of sync with safe area view Summary: Changelog: [Internal] # Problem SafeAreaView is getting reused, its previous `safeAreaInsets` is top: 44, bottom: 34 so `safeAreaInsetsDidChange` doesn't get called because it doesn't change. Therefore state gets never updates because `safeAreaInsetsDidChange` is never called. # Solution Update state whenever a new state is assigned. Reviewed By: shergin Differential Revision: D20444198 fbshipit-source-id: 75d1458450c70d74647df4962ddad88d5f6a38d2 --- .../SafeAreaView/RCTSafeAreaViewComponentView.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm index 22de8d9d1b7..00a1cb35a02 100644 --- a/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/SafeAreaView/RCTSafeAreaViewComponentView.mm @@ -49,6 +49,11 @@ using namespace facebook::react; { [super safeAreaInsetsDidChange]; + [self _updateStateIfNecessary]; +} + +- (void)_updateStateIfNecessary +{ if (!_state) { return; } @@ -78,6 +83,7 @@ using namespace facebook::react; oldState:(facebook::react::State::Shared const &)oldState { _state = std::static_pointer_cast(state); + [self _updateStateIfNecessary]; } + (ComponentDescriptorProvider)componentDescriptorProvider