Skip to content

refactor: improve image src update #39

@adonyssantos

Description

@adonyssantos

It's not recommended to use document when you are using React.

Where do you have this issue?

  • src/pages/PostForm.js
  • Check if it is in other files

As an alternative

You can create a state using useState to save the image metadata, such as src or alt, and update the data using the setter.

Example

setImagePreview(prev => { ...prev, url: imageUrl });

You just have to use that state in the src of the image, like this:

<img src={imagePreview.src} alt={imagePreview.alt} />

There are more alternatives that I invite you to investigate and use the one you consider most convenient.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions