Skip to content

packages/core/src/lib/hooks/use-svg-path.ts

Read as Markdown

This is the source snapshot used to build these API details. View this revision on GitHub.

Back to reference

1 import type { SvgPathOptions } from '../geometry/svg-path.js';
2 import { useValueMemoSlot } from './use-value-memo-slot.js';
3 import { createSvgPath } from '../geometry/svg-path.js';
4 
5 /**
6  * Creates a memoized Path2D for an SVG data string.
7  * @param svgPathData - SVG path data to parse and memoize.
8  * @returns A memoized Path2D
9  *
10  * @see {@link SvgPathOptions}
11  * @see {@link createSvgPath}
12  */
13 export function useSvgPath(svgPathData: string): Path2D {
14   return useValueMemoSlot(
15     'svgPath',
16     () => createSvgPath({ d: svgPathData }),
17     [svgPathData],
18   );
19 }
20 

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