Skip to content

Commit

Permalink
Back out "Use ConcreteStateTeller in RCTImageComponentView"
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shergin authored and facebook-github-bot committed Nov 12, 2020
1 parent 0e9296b commit eb6fefa
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ @interface RCTImageComponentView ()
@end

@implementation RCTImageComponentView {
ImageShadowNode::ConcreteStateTeller _stateTeller;
ImageShadowNode::ConcreteState::Shared _state;
ImageResponseObserverCoordinator const *_coordinator;
RCTImageResponseObserverProxy _imageResponseObserverProxy;
}
Expand Down Expand Up @@ -80,9 +80,9 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const &

- (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.
Expand Down Expand Up @@ -116,7 +116,7 @@ - (void)prepareForRecycle
[super prepareForRecycle];
self.coordinator = nullptr;
_imageView.image = nil;
_stateTeller.invalidate();
_state.reset();
}

- (void)dealloc
Expand All @@ -128,7 +128,7 @@ - (void)dealloc

- (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.
Expand Down

0 comments on commit eb6fefa

Please sign in to comment.