Field Notes
    Preparing search index...

    Function useElements

    • All elements; re-renders on every store mutation (use a selector for hot paths).

      Returns CanvasElement[]

    • Elements of one type; re-renders on every store mutation.

      Type Parameters

      • T extends "note" | "text" | "shape" | "stroke" | "arrow" | "image" | "html" | "extension"

      Parameters

      • type: T

      Returns (
          | Extract<StrokeElement, { type: T }>
          | Extract<NoteElement, { type: T }>
          | Extract<ArrowElement, { type: T }>
          | Extract<ImageElement, { type: T }>
          | Extract<HtmlElement, { type: T }>
          | Extract<TextElement, { type: T }>
          | Extract<ShapeElement, { type: T }>
          | Extract<ExtensionElementEnvelope, { type: T }>
      )[]

    • Derived value; re-renders only when the selected value changes (per isEqual, default: one-level shallow compare — arrays by index, plain objects by key, primitives by Object.is). Keep the selector referentially stable (useCallback or module scope).

      Supply isEqual for deeper structures. Note: selectors returning nested fresh objects (e.g. els => els.map(e => ({ ...e.position }))) still need a custom comparator because the default only compares one level deep.

      Type Parameters

      • R

      Parameters

      • selector: (elements: CanvasElement[]) => R
      • OptionalisEqual: (a: R, b: R) => boolean

      Returns R