Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ static inline Props::Shared cloneProps(
propsParserContext, shadowNode.getProps(), {});
}

auto viewProps = std::const_pointer_cast<BaseViewProps>(
std::static_pointer_cast<const BaseViewProps>(newProps));
for (auto& animatedProp : animatedProps.props) {
cloneProp(*viewProps, *animatedProp);
if (!animatedProps.props.empty()) {
if (auto viewProps = std::const_pointer_cast<BaseViewProps>(
std::dynamic_pointer_cast<const BaseViewProps>(newProps))) {
for (auto& animatedProp : animatedProps.props) {
cloneProp(*viewProps, *animatedProp);
}
}
}
return newProps;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ RootShadowNode::Unshared AnimationBackendCommitHook::shadowTreeWillCommit(
newProps = shadowNode.getComponentDescriptor().cloneProps(
propsParserContext, shadowNode.getProps(), {});
}
viewProps = std::const_pointer_cast<BaseViewProps>(
std::static_pointer_cast<const BaseViewProps>(newProps));
if (!snapshot->propNames.empty()) {
viewProps = std::const_pointer_cast<BaseViewProps>(
std::dynamic_pointer_cast<const BaseViewProps>(newProps));
}
}

for (const auto& propName : snapshot->propNames) {
updateProp(propName, *viewProps, *snapshot);
if (viewProps) {
for (const auto& propName : snapshot->propNames) {
updateProp(propName, *viewProps, *snapshot);
}
}

if (snapshot->text) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <react/renderer/animationbackend/AnimationBackend.h>
#include <react/renderer/components/root/RootComponentDescriptor.h>
#include <react/renderer/components/root/RootShadowNode.h>
#include <react/renderer/components/text/TextShadowNode.h>
#include <react/renderer/components/view/ViewShadowNode.h>
#include <react/renderer/element/ComponentBuilder.h>
#include <react/renderer/element/Element.h>
Expand Down Expand Up @@ -299,4 +300,67 @@ TEST_F(AnimationBackendTest, destroyingBackendUnregistersCommitHook) {
localUiManager->setDelegate(nullptr);
}

TEST_F(AnimationBackendTest, skipsTypedViewPropsForNonViewShadowNodes) {
constexpr SurfaceId kSurfaceId = 3;
std::shared_ptr<TextShadowNode> textNode;
std::shared_ptr<RootShadowNode> initialRoot;
builder.build(
Element<RootShadowNode>()
.surfaceId(kSurfaceId)
.tag(1)
.reference(initialRoot)
.children({Element<TextShadowNode>()
.surfaceId(kSurfaceId)
.tag(20)
.reference(textNode)}));

auto localUiManager = std::make_shared<UIManager>(
[](std::function<void(jsi::Runtime&)>&& /*callback*/) {},
contextContainer);
RecordingUIManagerDelegate localDelegate;
localUiManager->setDelegate(&localDelegate);

auto shadowTree = std::make_unique<ShadowTree>(
kSurfaceId,
LayoutConstraints{},
LayoutContext{},
*localUiManager,
*contextContainer);
auto* shadowTreePtr = shadowTree.get();

shadowTree->commit(
[&initialRoot](const RootShadowNode& /*oldRootShadowNode*/) {
return initialRoot;
},
{.mountSynchronously = true});

localUiManager->startEmptySurface(std::move(shadowTree));
auto localBackend = std::make_shared<AnimationBackend>(
std::make_shared<TestAnimationChoreographer>(), localUiManager);

localBackend->pushAnimationMutations([&textNode](AnimationTimestamp /*ts*/) {
AnimatedPropsBuilder propsBuilder;
propsBuilder.setOpacity(0.5);
AnimationMutations mutations;
mutations.batch.push_back(
AnimationMutation{
.tag = textNode->getTag(),
.family = textNode->getFamilyShared(),
.props = propsBuilder.get(),
.hasLayoutUpdates = true});
return mutations;
});

auto status = shadowTreePtr->commit(
[](const RootShadowNode& oldRootShadowNode) {
return std::make_shared<RootShadowNode>(
oldRootShadowNode, ShadowNodeFragment{});
},
{.source = ShadowTreeCommitSource::React});
EXPECT_EQ(status, ShadowTree::CommitStatus::Succeeded);

localUiManager->stopSurface(kSurfaceId);
localUiManager->setDelegate(nullptr);
}

} // namespace facebook::react
Loading