pdfrx_web
    Preparing search index...

    Function useViewerSnapshot

    • The plumbing every state hook in this package shares: subscribe to viewer events, re-read a value when they fire, and feed the result to React through useSyncExternalStore so it behaves under concurrent rendering.

      Two details make this work with object-shaped snapshots, which useSyncExternalStore otherwise loops on:

      • the value is recomputed only after a notification, not on every render;
      • isEqual lets a recomputed-but-unchanged value keep its previous identity, so React can bail out of the re-render.

      The viewer can be null (before PdfViewerSurface mounts, and during SSR), so getSnapshot must handle that.

      Type Parameters

      • T

      Parameters

      • subscribe: ViewerSubscribe

        The subscribe value (ViewerSubscribe).

      • getSnapshot: (viewer: PdfrxViewer | null) => T

        The getSnapshot value.

      • isEqual: (a: T, b: T) => boolean = Object.is

        The isEqual value.

      Returns T

      The current viewer snapshot state and actions.