runOnUIAsync
runOnUIAsync lets you asynchronously run workletized functions on the UI thread.
It returns a Promise of the worklet function's return value. The Promise is resolved asynchronously, not immediately after the callback execution.
To compare it with scheduleOnUI and runOnUISync, see Running worklet functions on the UI runtime.
Reference
Code
Colours connect each executing thread to its current code line. Recently executed lines fade over the next three ticks.
Console 0
No output yet


Type definitions
function runOnUIAsync<Args extends unknown[], ReturnValue>(
worklet: (...args: Args) => ReturnValue,
...args: Args
): Promise<ReturnValue>;
Arguments
worklet
A reference to a function you want to execute on the UI thread. Arguments to your function have to be passed after the function i.e. runOnUIAsync(setValue, 10);.
Remarks
-
It's a common mistake to execute function inside of
runOnUIAsynclike this:. Here, the correct usage would berunOnUIAsync(myWorklet(10))runOnUIAsync(myWorklet, 10). -
The callback passed as the argument is automatically workletized and ready to be run on the UI thread.
Call table
| Mode | RN Runtime | UI Runtime | Worker Runtime |
|---|---|---|---|
| Bundle Mode | ✅ | ✅ | ✅ |
| Legacy Eval Mode | ✅ | ❌ | ❌ |
Platform compatibility
| Native | Web |
|---|---|
| ✅ | ✅ |