funfelfonfafis
funfelfonfafis

Reputation: 187

Get value from array couses "Property 'value' does not exist on type"

I'm trying to pull out the data from array images. In ImageValue i have two strings: symbol and imageType. Why i get this error about property 'value'.

Error

Property 'value' does not exist on type 'ImageValue'

Array with data

enter image description here

Component

this.props.images.filter((image) =>
   image.value.symbol.toLowerCase().includes(this.state.searchSymbol.toLowerCase())
).map(image => (
    table.push(
       <div>{image.value.symbol + "." + image.value.imageType}</div>
    )
));

ImageValue

 class ImageValue {
    symbol: string;
    imageType: string;
}

Upvotes: 0

Views: 58

Answers (1)

Dennis Vash
Dennis Vash

Reputation: 53934

I think that you have mistaken typing the ImageValue:

type ImageValueType {
    value: { 
      symbol: string;
      imageType: string;
    }
}

Upvotes: 2

Related Questions