Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | import { MotionValue } from "../../value" type VariantNameList = string[] type VariantName = string | VariantNameList type UnresolvedVariant = VariantName | MotionValue const labelsToArray = (label?: VariantName): VariantNameList => { if (!label) { return [] } if (Array.isArray(label)) { return label } return [label] } export const resolveVariantLabels = ( variant?: UnresolvedVariant ): VariantNameList => { const unresolvedVariant = variant instanceof MotionValue ? (variant.get() as string) : variant return Array.from(new Set(labelsToArray(unresolvedVariant))) } /** * Hooks in React sometimes accept a dependency array as their final argument. (ie useEffect/useMemo) * When values in this array change, React re-runs the dependency. However if the array * contains a variable number of items, React throws an error. */ export const asDependencyList = (list: VariantNameList): string[] => [ list.join(","), ] |