Skip to content

Commit

Permalink
Clarify meaning of State constructor args (#39307)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39307

Make it explicit that the second arg for the State update constructor is the old State object, which we use to increment the revision.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D49008431

fbshipit-source-id: 649bdd136a4a6eb25858d8bfb7c41b725e593685
  • Loading branch information
javache authored and facebook-github-bot committed Sep 6, 2023
1 parent fb30fca commit 7ac5877
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class ConcreteState : public State {
/*
* Creates an updated `State` object with given previous one and `data`.
*/
explicit ConcreteState(const SharedData& data, const State& state)
: State(data, state) {}
explicit ConcreteState(const SharedData& data, const State& previousState)
: State(data, previousState) {}

/*
* Creates a first-of-its-family `State` object with given `family` and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

namespace facebook::react {

State::State(StateData::Shared data, const State& state)
: family_(state.family_),
State::State(StateData::Shared data, const State& previousState)
: family_(previousState.family_),
data_(std::move(data)),
revision_(state.revision_ + 1){};
revision_(previousState.revision_ + 1){};

State::State(StateData::Shared data, const ShadowNodeFamily::Shared& family)
: family_(family),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class State {
* Constructors are protected to make calling them directly with
* type-erasured arguments impossible.
*/
explicit State(StateData::Shared data, const State& state);
explicit State(StateData::Shared data, const State& previousState);
explicit State(
StateData::Shared data,
const ShadowNodeFamily::Shared& family);
Expand Down

0 comments on commit 7ac5877

Please sign in to comment.