Skip to main content
Version: 0.10-0.12

scheduleOnUI

scheduleOnUI lets you schedule a function to be executed on the UI Runtime. The callback executes asynchronously and doesn't return a value.

Reference​

import { scheduleOnUI } from 'react-native-worklets';

const myFunction = (): void => {
'worklet';
console.log('Hello from the UI Runtime!');
};

scheduleOnUI(myFunction); // Hello from the UI Runtime!

Type definitions

function scheduleOnUI<Args extends unknown[], ReturnValue>(
fun: (...args: Args) => ReturnValue,
...args: Args
): void;

Arguments​

fun​

A reference to a function you want to schedule on the UI Runtime.

args​

Arguments to pass to the function.

Remarks​

  • The callback passed as the argument is automatically workletized and ready to be run on the UI Runtime.

  • On the Web, scheduleOnUI schedules work to run on the next animation frame using requestAnimationFrame.

Call table​

ModeRN RuntimeUI RuntimeWorker Runtime
Bundle Mode✅✅✅
Legacy Eval Mode✅❌❌

What does it mean?

Platform compatibility​

NativeWeb
✅✅