Skip to main content

runOnUISync

runOnUISync lets you run a workletized function synchronously on the UI Runtime.

Reference

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

const myFunction = (num: number): number => {
'worklet';
return num + 1;
};

const result: number = runOnUISync(myFunction, 0);

console.log(result); // 1

Type definitions

function runOnUISync<Args extends unknown[], ReturnValue>(
worklet: (...args: Args) => ReturnValue,
...args: Args
): ReturnValue

Arguments

worklet

A function you want to execute on the UI Runtime.

args

Arguments to pass to the function.

Returns

runOnUISync returns the return value of the function passed as the first argument. It can only return values that can be converted to a Serializable.

Remarks