You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having some TypeScript issues trying to create a reusable UI component that uses NextUI's Image component with the NextImage component. Does anyone know how to create types for such a component which extends image props from both of these components?
I've tried several iterations, but here's one example of the component:
Type'{ src: string; alt: string; width?: number | `${number}` | undefined; height?: number | `${number}` | undefined; loading?: "lazy" | "eager" | undefined; key?: Key | null | undefined; crossOrigin?: CrossOrigin; ... 283 more ...; as: ForwardRefExoticComponent<...>; }'isnotassignabletotype'IntrinsicAttributes & MergeWithAs<Omit<DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, "ref">, Omit<...>, ImageProps, ForwardRefExoticComponent<...>>'.Type'{ src: string; alt: string; width?: number | `${number}` | undefined; height?: number | `${number}` | undefined; loading?: "lazy" | "eager" | undefined; key?: Key | null | undefined; crossOrigin?: CrossOrigin; ... 283 more ...; as: ForwardRefExoticComponent<...>; }'isnotassignabletotype'ImageProps'.Typesofproperty'onError'areincompatible.Type'ReactEventHandler<HTMLImageElement> | undefined'isnotassignabletotype'(() => void) | undefined'.Type 'ReactEventHandler<HTMLImageElement>' is not assignable to type '()=>void'.
Target signature provides too few arguments. Expected 1 or more, but got 0.ts(2322)
Am I perhaps doing this wrong? Should I build an image component from scratch with the useImage hook?
I also tried using extendVariants but ran into some issues with the slots and variants, wasn't sure if it was possible to extend this component and couldn't find an example of how to extend a component with slots and variants
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm having some TypeScript issues trying to create a reusable UI component that uses NextUI's Image component with the NextImage component. Does anyone know how to create types for such a component which extends image props from both of these components?
I've tried several iterations, but here's one example of the component:
Ref to the TypeScript error: https://typescript.tv/errors/#ts2322
Am I perhaps doing this wrong? Should I build an image component from scratch with the
useImage
hook?I also tried using
extendVariants
but ran into some issues with the slots and variants, wasn't sure if it was possible to extend this component and couldn't find an example of how to extend a component with slots and variantsBeta Was this translation helpful? Give feedback.
All reactions