Fix ignored initial value of TextInput

Summary: Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D19922731

fbshipit-source-id: b06f1d98d97a4ea46c60e07a89452ee77acded8d
This commit is contained in:
Samuel Susla 2020-02-19 07:01:06 -08:00 коммит произвёл Facebook Github Bot
Родитель 0e4bcaa296
Коммит 145151ef0f
3 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -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;

Просмотреть файл

@ -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();

Просмотреть файл

@ -25,6 +25,8 @@ class State {
public:
using Shared = std::shared_ptr<const State>;
static size_t constexpr initialRevisionValue = 1;
protected:
/*
* Constructors are protected to make calling them directly with