MCPcopy Create free account
hub / github.com/adobe/react-spectrum / useColor

Function useColor

packages/react-stately/src/color/useColor.ts:17–28  ·  view source on GitHub ↗
(value: string | Color | undefined | null)

Source from the content-addressed store, hash-verified

15import {useMemo} from 'react';
16
17export function useColor(value: string | Color | undefined | null): Color | null | undefined {
18 return useMemo(() => {
19 if (typeof value === 'string') {
20 try {
21 return parseColor(value);
22 } catch {
23 return undefined;
24 }
25 }
26 return value;
27 }, [value]);
28}

Callers 5

useColor.test.jsFile · 0.90
useConvertColorFunction · 0.90
useColorFieldStateFunction · 0.90
useColorPickerStateFunction · 0.90

Calls 1

parseColorFunction · 0.90

Tested by

no test coverage detected