mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
dc0ec22e79
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
41 lines
1.1 KiB
C++
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
|