Skip to content
Merged
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 @@ -51,6 +51,11 @@ public object DefaultNewArchitectureEntryPoint {
bridgelessEnabled || fabricEnabled

override fun useTurboModules(): Boolean = bridgelessEnabled || turboModulesEnabled

// Fixes reanimated flickering issues where shadow node updates on the UI thread wouldn't be
// propagated back to the react JS fiber node/tree.
override fun useRuntimeShadowNodeReferenceUpdate(): Boolean =
bridgelessEnabled || turboModulesEnabled
})

privateFabricEnabled = fabricEnabled
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,20 @@ void ShadowNode::setRuntimeShadowNodeReference(
runtimeShadowNodeReference_ = runtimeShadowNodeReference;
}

void ShadowNode::updateRuntimeShadowNodeReference(
const Shared& destinationShadowNode) const {
if (auto reference = runtimeShadowNodeReference_.lock()) {
reference->shadowNode = destinationShadowNode;
}
}

void ShadowNode::transferRuntimeShadowNodeReference(
const Shared& destinationShadowNode) const {
destinationShadowNode->runtimeShadowNodeReference_ =
runtimeShadowNodeReference_;

if (auto reference = runtimeShadowNodeReference_.lock()) {
reference->shadowNode = destinationShadowNode;
if (!ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdate()) {
updateRuntimeShadowNodeReference(destinationShadowNode);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ class ShadowNode : public Sealable,
void setRuntimeShadowNodeReference(const std::shared_ptr<ShadowNodeWrapper>&
runtimeShadowNodeReference) const;

/*
* Update the runtime reference to point to the provided shadow node.
*/
void updateRuntimeShadowNodeReference(
const Shared& destinationShadowNode) const;

/*
* Transfer the runtime reference to this `ShadowNode` to a new instance,
* updating the reference to point to the new `ShadowNode` referencing it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "updateMountedFlag.h"

#include <react/featureflags/ReactNativeFeatureFlags.h>

namespace facebook::react {
void updateMountedFlag(
const ShadowNode::ListOfShared& oldChildren,
Expand Down Expand Up @@ -47,6 +49,10 @@ void updateMountedFlag(
newChild->setMounted(true);
oldChild->setMounted(false);

if (ReactNativeFeatureFlags::useRuntimeShadowNodeReferenceUpdate()) {
newChild->updateRuntimeShadowNodeReference(newChild);
}

updateMountedFlag(oldChild->getChildren(), newChild->getChildren());
}

Expand Down
Loading