@posit-dev/shinyreact
    Preparing search index...

    Function useSetShinyInput

    • A write-only React hook that returns just the setter for a Shiny input.

      Use this when a component only needs to write an input value — typically a button, action handler, or anything that pushes events into the reactive graph but never reads the current value back. Mirrors Jotai's useSetAtom pattern: explicit at the call site that this is a producer, not a reader, and avoids the spurious re-renders that useShinyInput would incur from subscribing to its own value updates.

      Same defaultValue and options semantics as useShinyInput — this hook registers the input on mount, so its defaultValue seeds the registry the same way.

      Type Parameters

      • T

      Parameters

      • id: string

        The Shiny input ID (input$<id>).

      • defaultValue: T

        Initial value for the input, captured on first mount.

      • options: {
            debounceMs?: number;
            namespace?: string | null;
            priority?: EventPriority;
            type?: string;
        } = {}

        Optional configuration object.

        • OptionaldebounceMs?: number

          Debounce delay in milliseconds for input updates (default: 100).

        • Optionalnamespace?: string | null

          Module namespace to apply (or null to suppress the surrounding ShinyModuleProvider namespace).

        • Optionalpriority?: EventPriority

          Priority level for the input event.

        • Optionaltype?: string

          Optional input-handler name appended as ${id}:${type} when sending to Shiny. Use to route values through a Shiny input handler such as "shiny.datetime". Must be non-empty and contain no whitespace or :. The first mount of a given id finalizes the policy (an explicit type or the absence of one); a later mount that omits type is a no-op, but a later mount that supplies a type disagreeing with the finalized policy throws — the handler name is a server-side semantic and must be consistent across every useShinyInput / useSetShinyInput call for the same id.

      Returns Dispatch<SetStateAction<T>>

      A function that writes the input value.