Nextjs Image alt attribute and typeError.
Answered
Yellow croaker posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Yellow croakerOP
Hello i'm trying to give an alt attribute for Image
My nextJs Image looks like this:
I get this kind warning/error to my alt attribute:
My nextJs Image looks like this:
{resume.personalInfo?.imagePath && (
<Image
key={resume.personalInfo.imagePath}
src={resume.personalInfo.imagePath}
style={styles.image}
alt="Picture of the author"
/>
)}
I get this kind warning/error to my alt attribute:
No overload matches this call.
Overload 1 of 2, '(props: ImageProps | Readonly<ImageProps>): Image', gave the following error.
Type '{ key: string; src: string; style: { marginBottom: number; }; alt: string; }' is not assignable to type 'IntrinsicAttributes & (IntrinsicClassAttributes<Image> & Readonly<ImageProps>)'.
Property 'alt' does not exist on type 'IntrinsicAttributes & (IntrinsicClassAttributes<Image> & Readonly<ImageProps>)'.
Overload 2 of 2, '(props: ImageProps, context: any): Image', gave the following error.
Type '{ key: string; src: string; style: { marginBottom: number; }; alt: string; }' is not assignable to type 'IntrinsicAttributes & (IntrinsicClassAttributes<Image> & Readonly<ImageProps>)'.
Property 'alt' does not exist on type 'IntrinsicAttributes & (IntrinsicClassAttributes<Image> & Readonly<ImageProps>)'.ts(2769)
(property) alt: string
4 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
English Angora
Did you import Image from next/image
![Avatar](https://cdn.discordapp.com/avatars/603291340528287791/642e035d0c8359e8964c7d6c36b2f7fa.webp?size=256)
Pearls
Make sure you have the correct import (import Image from 'next/image';), and make sure your using it in a client component
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Yellow croakerOP
thanks seems that i had wrong import going on there!
Answer
![Avatar](https://cdn.discordapp.com/avatars/603291340528287791/642e035d0c8359e8964c7d6c36b2f7fa.webp?size=256)
Pearls
No worries!