Files
react-native/ReactCommon/fabric/core/state/State.cpp
T
Valentin Shergin dc0ec22e79 Fabric: Removing unnecessary code from State.cpp
Summary:
Why crash in production if we can make potential bug not compile?

Changelog: [INTERNAL]

Reviewed By: sammy-SC

Differential Revision: D18499813

fbshipit-source-id: dc2d7ac12b8a2ae27d1e6b832fccc1555cab3b75
2019-11-14 10:38:24 -08:00

41 lines
1.1 KiB
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "State.h"
#include <glog/logging.h>
#include <react/core/ShadowNode.h>
#include <react/core/ShadowNodeFragment.h>
#include <react/core/State.h>
#include <react/core/StateTarget.h>
#include <react/core/StateUpdate.h>
#ifdef ANDROID
#include <folly/dynamic.h>
#endif
namespace facebook {
namespace react {
State::State(State const &state) : stateCoordinator_(state.stateCoordinator_){};
State::State(StateCoordinator::Shared const &stateCoordinator)
: stateCoordinator_(stateCoordinator){};
void State::commit(std::shared_ptr<ShadowNode const> const &shadowNode) const {
stateCoordinator_->setTarget(StateTarget{shadowNode});
}
State::Shared State::getMostRecentState() const {
auto target = stateCoordinator_->getTarget();
return target ? target.getShadowNode().getState()
: ShadowNodeFragment::statePlaceholder();
}
} // namespace react
} // namespace facebook