Functions & Hooks

useClock

function useClock(): SharedValueLike<number>;

Seconds since the first frame, as a SharedValue.

Written on the UI thread, so feeding it to a shader uniform animates without re-encoding the scene from JS.

Seconds rather than milliseconds because the value is usually bound for a shader uniform, and GLSL ES mediump floats stop being representable above 65504: a millisecond clock turns every shader that reads it black after about a minute of uptime, silently. Seconds buy eighteen hours instead.

Returns

SharedValueLike<number>

On this page