diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp index 239282df391..eb94a05d303 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.cpp +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.cpp @@ -120,7 +120,7 @@ const State::Shared &ShadowNode::getState() const { return state_; } -const State::Shared &ShadowNode::getCommitedState() const { +State::Shared ShadowNode::getCommitedState() const { return state_ ? state_->getCommitedState() : ShadowNodeFragment::statePlaceholder(); } diff --git a/ReactCommon/fabric/core/shadownode/ShadowNode.h b/ReactCommon/fabric/core/shadownode/ShadowNode.h index 773406b4df1..8b99108258e 100644 --- a/ReactCommon/fabric/core/shadownode/ShadowNode.h +++ b/ReactCommon/fabric/core/shadownode/ShadowNode.h @@ -115,7 +115,7 @@ class ShadowNode : public virtual Sealable, * Returns a momentary value of currently committed state associated with a * family of nodes which this node belongs to. */ - const State::Shared &getCommitedState() const; + State::Shared getCommitedState() const; /* * Returns a local data associated with the node. diff --git a/ReactCommon/fabric/core/state/State.cpp b/ReactCommon/fabric/core/state/State.cpp index b3c6af53022..edb79c895b3 100644 --- a/ReactCommon/fabric/core/state/State.cpp +++ b/ReactCommon/fabric/core/state/State.cpp @@ -29,7 +29,7 @@ void State::commit(const ShadowNode &shadowNode) const { stateCoordinator_->setTarget(StateTarget{shadowNode}); } -const State::Shared &State::getCommitedState() const { +State::Shared State::getCommitedState() const { return stateCoordinator_->getTarget().getShadowNode().getState(); } diff --git a/ReactCommon/fabric/core/state/State.h b/ReactCommon/fabric/core/state/State.h index f13f551eda7..dbf7973fa07 100644 --- a/ReactCommon/fabric/core/state/State.h +++ b/ReactCommon/fabric/core/state/State.h @@ -48,7 +48,7 @@ class State { /* * Must be used by `ShadowNode` *only*. */ - const State::Shared &getCommitedState() const; + State::Shared getCommitedState() const; }; } // namespace react