Skip to main content
Version: Unreleased

isRNRuntime

Available from 0.8.0

Checks if the current runtime is the React Native Runtime.

Reference​

Code

Code

Colours connect each executing thread to its current code line. Recently executed lines fade over the next three ticks.

function checkUI() {
'worklet';
console.log(isRNRuntime()); // false (UI Runtime)
}
function checkWorker() {
'worklet';
console.log(isRNRuntime()); // false (Worker Runtime)
}
console.log(isRNRuntime()); // true (RN Runtime)
scheduleOnUI(checkUI);
const workerRuntime = createWorkletRuntime({ name: 'background' });
scheduleOnRuntime(workerRuntime, checkWorker);

Type definitions

function isRNRuntime(): boolean;

Returns​

true if the current runtime is the RN Runtime, false otherwise.

Remarks​

  • The function checks the value of globalThis.__RUNTIME_KIND to determine the kind of the current runtime. See getRuntimeKind for more details.

We are Software Mansion.