Back out "Use ConcreteStateTeller in RCTImageComponentView"

Summary: We don't need ConcreteStateTeller in <Image> 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
This commit is contained in:
Valentin Shergin
2020-11-11 16:41:56 -08:00
committed by Facebook GitHub Bot
parent 0e9296b95d
commit eb6fefa508
@@ -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<ImageShadowNode::ConcreteState const>(state);
auto _oldState = std::static_pointer_cast<ImageShadowNode::ConcreteState const>(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.