Accessor / Setter / Signal / SourceAccessor
A zero-arg getter for a reactive value. Calling it inside a tracking scope (memo, effect compute, JSX expression) subscribes the scope to changes.
Reading outside any tracking scope simply returns the current value without creating a subscription.
Import
import type { Accessor } from "solid-js";Type signature
type Accessor<T> = () => T;A signal setter. Accepts either a new value or an updater (prev) => next.
If the type permits undefined, setState() (no args) clears to undefined.
To store a function as the value itself (rather than as an updater), wrap it
with an updater: setHandler(() => myHandler).
Import
import type { Setter } from "solid-js";Type signature
type Setter<in out T> = { <U extends T>( ...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)] ): undefined extends T ? undefined : U; <U extends T>(value: (prev: T) => U): U; <U extends T>(value: Exclude<U, Function>): U; <U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;};A [get, set] pair returned from createSignal / createOptimistic.
Import
import type { Signal } from "solid-js";Type signature
type Signal<T> = [get: SourceAccessor<T>, set: Setter<T>];SourceAccessor API reference.
Import
import type { SourceAccessor } from "solid-js";Type signature
type SourceAccessor<T> = Refreshable<Accessor<T>>;