isWorkletFunction
isWorkletFunction checks if a function is a worklet function. It only works with the Worklet Syntax plugin enabled. Unless you are doing something with internals of the Worklets library you shouldn't need to use this function.
Reference
Both checks run on the RN Runtime. Checking a function doesn't execute it or schedule it on another thread.
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
type WorkletClosure = unknown[];
interface WorkletProps {
__closure?: WorkletClosure;
__workletHash: number;
/** Only in dev builds. */
__pluginVersion?: string;
}
type WorkletFunction<
TArgs extends unknown[] = unknown[],
TReturn = unknown,
> = ((...args: TArgs) => TReturn) & WorkletProps;
function isWorkletFunction<
Args extends unknown[] = unknown[],
ReturnValue = unknown,
>(value: unknown): value is WorkletFunction<Args, ReturnValue>;
Arguments
value
A function to check if it is a worklet function.
Returns
isWorkletFunction returns a boolean value.
Remarks
-
Call it on the RN Runtime. On a Worklet Runtime, it returns
falseeven for worklet functions. -
Call it only after the worklet function is declared. Before the declaration, it never returns
true.isWorkletFunction(myWorklet); // Never returns true.
function myWorklet() {
'worklet';
}