import type { MotiPressableInteractionState } from './types' import { useAnimatedProps } from 'react-native-reanimated' import { MotiPressableInteractionIds, useMotiPressableContext } from './context' import { useFactory } from './use-validate-factory-or-id' type Factory = (interaction: MotiPressableInteractionState) => Props /** * Replacement for `useAnimatedProps`, which receives the interaction state as the first argument. * @param factory function that receives the interaction state and returns the props */ export function useMotiPressableAnimatedProps( id: MotiPressableInteractionIds['id'], factory: Factory, deps?: readonly any[] ): Partial export function useMotiPressableAnimatedProps( factory: Factory, deps?: readonly any[] ): Partial export function useMotiPressableAnimatedProps( factoryOrId: Factory | MotiPressableInteractionIds['id'], maybeFactoryOrDeps?: Factory | readonly any[], maybeDeps?: readonly any[] ) { const context = useMotiPressableContext() const { factory, id, deps } = useFactory>( 'useMotiPressableAnimatedProps', factoryOrId, maybeFactoryOrDeps, maybeDeps ) return useAnimatedProps(() => { return context ? factory(context.containers[id].value) : {} }, deps) }