Skip to content

ImageUploader does not work with useState variable #141

@elliotBraem

Description

@elliotBraem

The ImageUploader component uploads to IPFS and sets the value of the state variable provided.

However, this does not work with the new useState.

Working code:

State.init({
  img: null,
});

return (
  <div className='container row'>
    <div>
      Image upload: <br />
      <IpfsImageUpload image={state.img} />
    </div>
   </div>);

Breaks when replaced with useState variable:

const [img, setImg] = useState(null);

return (
  <div className="container row">
    <div>
      Image upload: <br />
      <IpfsImageUpload image={img} />
    </div>
   </div>
);

It gives error:

Screenshot 2023-10-13 at 4 43 25 PM

See this widget for example.


Could this be fixed with a "onChange" instead of image={} ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions