[]previous and next page

MemoOptions

Options of useMemo.

Options of useMemo.

Import#

ts
import type { MemoOptions } from "@shadow-js/core";

Signature#

ts
interface MemoOptions<T> {
  /**
   * Decides whether a recomputation changed the value: readers are notified only when it returns
   * `false`. `false` always propagates.
   * @default Object.is
   */
  equals?: Equals<T>;
  /**
   * Skip the initial computation until the first read. Without it the memo computes once when it
   * is created.
   * @default false
   */
  lazy?: boolean;
  /**
   * Label shown by devtools and diagnostics.
   * @default undefined (the memo is unnamed)
   */
  name?: string;
  /**
   * Turn off the development check that rejects signal writes while this memo computes. Set it for
   * a memo that builds children (components, `ref` callbacks, directives), where the code that runs
   * is setup and may write a counter or a registry; the control-flow components do. A memo that
   * derives a value must leave it off.
   * @default false
   */
  allowWrites?: boolean;
}

Members#

Name Type Description
T T
equals? equals?: Equals<T> Decides whether a recomputation changed the value: readers are notified only when it returns false. false always propagates.
lazy? lazy?: boolean Skip the initial computation until the first read. Without it the memo computes once when it is created.
name? name?: string Label shown by devtools and diagnostics.
allowWrites? allowWrites?: boolean Turn off the development check that rejects signal writes while this memo computes. Set it for a memo that builds children (components, ref callbacks, directives), where the code that runs is setup and may write a counter or a registry; the control-flow components do. A memo that derives a value must leave it off.