• Subscribe to a slice of the graph with shallow-equal dedup.

    Type Parameters

    • T

      The selector's return type, typically an object or array literal composed inside the selector.

    Parameters

    • selector: Selector<T>

      Pure projection from the current Graph to the value the component cares about.

    Returns T

    The currently-selected value; changes between renders only when shallowEqual reports a difference against the previous return.

    Error when called outside <CauslProvider>.

    Use this in place of useCausl when the selector returns a freshly-constructed wrapper that would otherwise force a render on every commit. The cache is invalidated if the host swaps the graph handle on the provider.

    const { a, b } = useCauslShallow((g) => ({
    a: g.read(aNode),
    b: g.read(bNode),
    }))