Function useSetSignal

  • React hook returning only a setter function for an Alien Signal. No current value is provided, similar to Jotai's useSetAtom.

    Type Parameters

    • T

      The type of the signal value.

    Parameters

    • alienSignal: IWritableSignal<T>

      The signal to write.

    Returns (val: T | (oldVal: T) => T) => void

    A setter function.

    const countSignal = createSignal(0);
    function Incrementor() {
    const setCount = useSetSignal(countSignal);
    return <button onClick={() => setCount((c) => c + 1)}>+1</button>;
    }