useTransient

Returns an environment's current reading on a transient channel, re-rendering when it changes, or null when there is none.

@internote/canvas-sdk/reactHook
On this page
import { useTransient } from '@internote/canvas-sdk/react';

The subscription half of createTransientValue. On the server it reads as null, since the surface that publishes has not run there.

#Signature

<T>(channel: TransientValue<T>, where: Addressed): T | null

#Parameters

channel
The channel, declared beside the surface that publishes it.
where
Which environment to read, usually ctx.

#Example

const cursor = useTransient(cursorReading, ctx);
return <FooterReadout>{cursor ? `${cursor.x.toFixed(2)}, ${cursor.y.toFixed(2)}` : '—'}</FooterReadout>;

Declared in packages/canvas-sdk/src/react/use-transient.ts:46.

Last updated