diff --git a/frontend/components/animate-ui/primitives/animate/slot.tsx b/frontend/components/animate-ui/primitives/animate/slot.tsx index d52ee0a6..04ada8c8 100644 --- a/frontend/components/animate-ui/primitives/animate/slot.tsx +++ b/frontend/components/animate-ui/primitives/animate/slot.tsx @@ -1,7 +1,12 @@ 'use client'; import * as React from 'react'; -import { type HTMLMotionProps, isMotionComponent, motion } from 'motion/react'; +import { + type HTMLMotionProps, + type MotionValue, + isMotionComponent, + motion, +} from 'motion/react'; import { cn } from '@/lib/utils'; type AnyProps = Record; @@ -16,8 +21,7 @@ type WithAsChild = | (Base & { asChild?: false | undefined }); type SlotProps = { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - children?: any; + children?: React.ReactNode | MotionValue | MotionValue; } & DOMMotionProps; function mergeRefs( @@ -63,21 +67,24 @@ function Slot({ ref, ...props }: SlotProps) { + const isValidChild = React.isValidElement(children); + const childrenType = isValidChild ? children.type : undefined; + const isAlreadyMotion = - typeof children.type === 'object' && - children.type !== null && - isMotionComponent(children.type); + isValidChild && + typeof childrenType === 'object' && + childrenType !== null && + isMotionComponent(childrenType); const Base = React.useMemo( () => isAlreadyMotion - ? (children.type as React.ElementType) - : motion.create(children.type as React.ElementType), - [isAlreadyMotion, children.type], + ? (childrenType as React.ElementType) + : motion.create(childrenType as React.ElementType), + [isAlreadyMotion, childrenType], ); - if (!React.isValidElement(children)) return null; - + if (!isValidChild) return null; const { ref: childRef, ...childProps } = children.props as AnyProps; const mergedProps = mergeProps(childProps, props); diff --git a/frontend/hooks/use-controlled-state.tsx b/frontend/hooks/use-controlled-state.tsx index 1b5eec23..b4ca8cfe 100644 --- a/frontend/hooks/use-controlled-state.tsx +++ b/frontend/hooks/use-controlled-state.tsx @@ -14,8 +14,7 @@ interface CommonControlledStateProps { * const [value, setValue] = useControlledState({ value: propValue, onChange: console.log }) * ``` */ -// eslint-disable-next-line @typescript-eslint/no-explicit-any -export function useControlledState( +export function useControlledState( props: CommonControlledStateProps & { onChange?: (value: T, ...args: Rest) => void; },