Create tryDispatchMountItems runnable only when needed (#53196)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53196

In the FabricUIManager, the runnable created for scheduled mounts is only used if currently running on the UI thread.

With this diff the runnable only gets created when needed.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D79969412

fbshipit-source-id: ee78890322af8580357389aad8357f7c0d18490f
This commit is contained in:
Nick Lefever
2025-08-11 14:45:36 -07:00
committed by Facebook GitHub Bot
parent 6738dbcc7e
commit cc71f9c550
@@ -935,14 +935,14 @@ public class FabricUIManager
if (shouldSchedule) {
Assertions.assertNotNull(mountItem, "MountItem is null");
mMountItemDispatcher.addMountItem(mountItem);
Runnable runnable =
new GuardedRunnable(mReactApplicationContext) {
@Override
public void runGuarded() {
mMountItemDispatcher.tryDispatchMountItems();
}
};
if (UiThreadUtil.isOnUiThread()) {
Runnable runnable =
new GuardedRunnable(mReactApplicationContext) {
@Override
public void runGuarded() {
mMountItemDispatcher.tryDispatchMountItems();
}
};
runnable.run();
}
}