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,
scheduleOnUIschedules work to run on the next animation frame usingrequestAnimationFrame.
Call table
| Bundle Mode | RN Runtime | UI Runtime | Worker Runtime |
|---|---|---|---|
| Enabled | ✅ | ✅ | ✅ |
| Disabled | ✅ | ❌ | ❌ |
Platform compatibility
| Native | Web |
|---|---|
| ✅ | ✅ |