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 | 33x 33x 33x 33x 1412x 1412x 736x 2824x | import { useContext, useMemo } from "react" import { MotionContext, MotionContextProps } from "." import { MotionProps } from "../../motion/types" import { getCurrentTreeVariants } from "./utils" export function useCreateMotionContext(props: MotionProps): MotionContextProps { const { initial, animate } = getCurrentTreeVariants( props, useContext(MotionContext) ) return useMemo( () => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)] ) } function variantLabelsAsDependency( prop: undefined | string | string[] | boolean ) { return Array.isArray(prop) ? prop.join(" ") : prop } |