0

How can I correctly load this image?

import image_1 from "../../static_media/1.png"

handleClick = async (e) => {
    
    this.loadImage({
        "0": {
            name: "1.png",
            image: image_1,
            backend_address: await fetch(image_1).then(res => res.blob())
        }})
    }

When I do console.log(this.state.files[0])

I get

backend_address: Blob {size: 736023, type: 'image/png'} image: "/static/media/1.46b58831.png" name: "1.png" [[Prototype]]: Object

When I do the following

<Image src={this.state.files[0].image} />

I get

TypeError: Cannot read properties of undefined (reading 'image')

1 Answer 1

1

Try this:

  <Image src={this.state.files[0]?.image} />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.