Function useSetSignal

  • React hook that returns only a setter function for a writable signal. This is similar to Jotai's useSetAtom and can be helpful when you only need to update state.

    Type Parameters

    • T

      The type of the signal value.

    Parameters

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

    A setter function to update the signal.

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