File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed
ReactCommon/fabric/components/view/tests Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change 1818#include < react/element/testUtils.h>
1919#include < react/uimanager/ComponentDescriptorProviderRegistry.h>
2020
21- using namespace facebook ::react;
21+ namespace facebook {
22+ namespace react {
2223
2324class YogaDirtyFlagTest : public ::testing::Test {
2425 protected:
@@ -191,3 +192,30 @@ TEST_F(YogaDirtyFlagTest, reversingListOfChildrenMustDirtyYogaNode) {
191192 EXPECT_TRUE (
192193 static_cast <RootShadowNode &>(*newRootShadowNode).layoutIfNeeded ());
193194}
195+
196+ TEST_F (YogaDirtyFlagTest, updatingStateForScrollViewMistNotDirtyYogaNode) {
197+ /*
198+ * Updating a state for *some* (not all!) components must *not* dirty Yoga
199+ * nodes.
200+ */
201+ auto newRootShadowNode = rootShadowNode_->cloneTree (
202+ scrollViewShadowNode_->getFamily (), [](ShadowNode const &oldShadowNode) {
203+ auto state = ScrollViewState{};
204+ state.contentOffset = Point{42 , 9000 };
205+
206+ auto &componentDescriptor = oldShadowNode.getComponentDescriptor ();
207+ auto newState = componentDescriptor.createState (
208+ oldShadowNode.getFamily (),
209+ std::make_shared<ScrollViewState>(state));
210+
211+ return oldShadowNode.clone ({ShadowNodeFragment::propsPlaceholder (),
212+ ShadowNodeFragment::childrenPlaceholder (),
213+ newState});
214+ });
215+
216+ EXPECT_FALSE (
217+ static_cast <RootShadowNode &>(*newRootShadowNode).layoutIfNeeded ());
218+ }
219+
220+ } // namespace react
221+ } // namespace facebook
You can’t perform that action at this time.
0 commit comments