Fabric: Implemented StubViewTree::getRootStubView()

Summary:
Trivial.
Before that we didn't have a way to get a root node from a Tree object.
It's useful during debugging (and some coming changes use that).

Reviewed By: mdvacca

Differential Revision: D16342529

fbshipit-source-id: 27c7516f3b3fccc8d8b25d4d2748006f7958ae41
This commit is contained in:
Valentin Shergin 2019-07-17 14:11:20 -07:00 коммит произвёл Facebook Github Bot
Родитель 1e45a41dc2
Коммит 27ac090e1c
2 изменённых файлов: 8 добавлений и 0 удалений

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

@ -11,9 +11,14 @@ namespace react {
StubViewTree::StubViewTree(ShadowView const &shadowView) {
auto view = std::make_shared<StubView>();
view->update(shadowView);
rootTag = shadowView.tag;
registry[shadowView.tag] = view;
}
StubView const &StubViewTree::getRootStubView() const {
return *registry.at(rootTag);
}
void StubViewTree::mutate(ShadowViewMutationList const &mutations) {
for (auto const &mutation : mutations) {
switch (mutation.type) {

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

@ -21,6 +21,9 @@ class StubViewTree {
void mutate(ShadowViewMutationList const &mutations);
StubView const &getRootStubView() const;
Tag rootTag;
std::unordered_map<Tag, StubView::Shared> registry{};
};