Skip to main content
Version: 0.10

getCurrentThreadId

Available from 0.13.0

getCurrentThreadId returns the id of the thread which currently executes JavaScript on the calling Runtime. The returned id is a stringified result of std::this_thread::get_id().

Reference

import { getCurrentThreadId, runOnUISync, scheduleOnUI } from 'react-native-worklets';

console.log(getCurrentThreadId()); // The JS thread id.

scheduleOnUI(() => {
'worklet';
console.log(getCurrentThreadId()); // The UI thread id.
});

runOnUISync(() => {
'worklet';
console.log(getCurrentThreadId()); // The JS thread id.
})

Type definitions

function getCurrentThreadId(): string;

Returns

getCurrentThreadId returns a string with the id of the current thread. The format of the id is platform-specific.

Call table

ModeRN RuntimeUI RuntimeWorker Runtime
Bundle Mode
Legacy Eval Mode

What does it mean?

Platform compatibility

NativeWeb