diff --git a/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.cpp b/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.cpp index b0d32e406e..5678cfc9b2 100644 --- a/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.cpp +++ b/ReactCommon/fabric/components/textinput/iostextinput/TextInputShadowNode.cpp @@ -19,7 +19,8 @@ namespace react { extern char const TextInputComponentName[] = "TextInput"; AttributedStringBox TextInputShadowNode::attributedStringBoxToMeasure() const { - bool hasMeaningfulState = getState() && getState()->getRevision() != 0; + bool hasMeaningfulState = + getState() && getState()->getRevision() != State::initialRevisionValue; if (hasMeaningfulState) { auto attributedStringBox = getStateData().attributedStringBox; @@ -66,7 +67,7 @@ void TextInputShadowNode::setTextLayoutManager( void TextInputShadowNode::updateStateIfNeeded() { ensureUnsealed(); - if (!getState() || getState()->getRevision() == 0) { + if (!getState() || getState()->getRevision() == State::initialRevisionValue) { auto state = TextInputState{}; state.attributedStringBox = AttributedStringBox{getAttributedString()}; state.paragraphAttributes = getConcreteProps().paragraphAttributes; diff --git a/ReactCommon/fabric/core/state/State.cpp b/ReactCommon/fabric/core/state/State.cpp index 46c63e77b1..d6fb8afe8e 100644 --- a/ReactCommon/fabric/core/state/State.cpp +++ b/ReactCommon/fabric/core/state/State.cpp @@ -21,7 +21,7 @@ State::State(StateData::Shared const &data, State const &state) State::State( StateData::Shared const &data, ShadowNodeFamily::Shared const &family) - : family_(family), data_(data), revision_{1} {}; + : family_(family), data_(data), revision_{State::initialRevisionValue} {}; State::Shared State::getMostRecentState() const { auto family = family_.lock(); diff --git a/ReactCommon/fabric/core/state/State.h b/ReactCommon/fabric/core/state/State.h index eeaaa80f0e..e48cf15c3d 100644 --- a/ReactCommon/fabric/core/state/State.h +++ b/ReactCommon/fabric/core/state/State.h @@ -25,6 +25,8 @@ class State { public: using Shared = std::shared_ptr; + static size_t constexpr initialRevisionValue = 1; + protected: /* * Constructors are protected to make calling them directly with