Skip to content

useLinePath

Read as Markdown

import { useLinePath, Path } from "@pibbl/core";

useLinePath(coords, { closePath? }?) is render-only and memoizes a fresh numeric line path while its flattened coordinates and close flag are unchanged. It has no separate cleanup; normal component slot teardown owns the memo.

function Sparkline() {
const path = useLinePath([
[0, 24],
[30, 8],
[60, 18],
]);
return <Path style={{ d: path, stroke: "#2563eb" }} />;
}

See the Line live example.

Creates a memoized Path2D for a set of line coordinates.

useLinePath: (coords: [number, number][], config?: { closePath?: boolean; }) => Path2D

Related API: useLinePath.

  • coords — Ordered horizontal and vertical coordinate pairs.

  • config — Whether to close the path by connecting its last vertex to its first.

A memoized Path2D

LinePathOptions

createLinePath

View source — packages/core/src/lib/hooks/use-line-path.ts:14

Read the Drawing, layout, and effects companion for ownership, adaptation, failure modes, and verification. Agent start provides the version-selection workflow.

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.