mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: ShadowNode::getCommitedState() now returns by value
Summary: Returning a shared pointer by const reference in this context is not correct/safe because the object (the ShadowNode) doesn't own the object, so the caller cannot reason about the lifetime (esp. in a multithreaded environment). Reviewed By: mdvacca Differential Revision: D15958737 fbshipit-source-id: 8f03e6530d07d63ece5f955055c5c67c204b8223
This commit is contained in:
committed by
Facebook Github Bot
parent
3915c0fa61
commit
bd19f3bd13
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class State {
|
||||
/*
|
||||
* Must be used by `ShadowNode` *only*.
|
||||
*/
|
||||
const State::Shared &getCommitedState() const;
|
||||
State::Shared getCommitedState() const;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
Reference in New Issue
Block a user