From eb6fefa508bef0699ca432d8e24f11b793390705 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 11 Nov 2020 16:41:56 -0800 Subject: [PATCH] Back out "Use ConcreteStateTeller in RCTImageComponentView" Summary: We don't need ConcreteStateTeller in component because we don't even update the state from the component. I will change the logic around the state in the next diff, so we have to remove ConcreteStateTeller first. Reviewed By: sammy-SC Differential Revision: D24880822 fbshipit-source-id: bc993bc04ef9f6df79bcbc51941ad6bf64baae58 --- .../ComponentViews/Image/RCTImageComponentView.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm index 9e66149b98d..6847214e00b 100644 --- a/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm @@ -22,7 +22,7 @@ using namespace facebook::react; @end @implementation RCTImageComponentView { - ImageShadowNode::ConcreteStateTeller _stateTeller; + ImageShadowNode::ConcreteState::Shared _state; ImageResponseObserverCoordinator const *_coordinator; RCTImageResponseObserverProxy _imageResponseObserverProxy; } @@ -80,9 +80,9 @@ using namespace facebook::react; - (void)updateState:(State::Shared const &)state oldState:(State::Shared const &)oldState { - _stateTeller.setConcreteState(state); + _state = std::static_pointer_cast(state); auto _oldState = std::static_pointer_cast(oldState); - auto data = _stateTeller.getData().value(); + auto data = _state->getData(); // This call (setting `coordinator`) must be unconditional (at the same block as setting `State`) // because the setter stores a raw pointer to object that `State` owns. @@ -116,7 +116,7 @@ using namespace facebook::react; [super prepareForRecycle]; self.coordinator = nullptr; _imageView.image = nil; - _stateTeller.invalidate(); + _state.reset(); } - (void)dealloc @@ -128,7 +128,7 @@ using namespace facebook::react; - (void)didReceiveImage:(UIImage *)image metadata:(id)metadata fromObserver:(void const *)observer { - if (!_eventEmitter || !_stateTeller.isValid()) { + if (!_eventEmitter || !_state) { // Notifications are delivered asynchronously and might arrive after the view is already recycled. // In the future, we should incorporate an `EventEmitter` into a separate object owned by `ImageRequest` or `State`. // See for more info: T46311063.