Skip to content

Documentation / @agentick/core / useSignal

Function: useSignal()

useSignal<T>(initialValue): Signal<T>

Defined in: core/src/hooks/signal.ts:701

Create a signal - reactive state that can trigger reconciliation.

Unlike useState, signals:

  • Can be read outside of render
  • Can be subscribed to
  • Don't cause immediate re-render (schedule reconcile instead)

Type Parameters

T

T

Parameters

initialValue

T

Returns

Signal<T>

Example

tsx
const MyComponent = () => {
  const count = useSignal(0);

  const handleClick = () => {
    count.set(c => c + 1);
  };

  return <Section>Count: {count()}</Section>;
};

Released under the ISC License.