Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageUploader does not work with useState variable #141

Open
elliotBraem opened this issue Oct 13, 2023 · 1 comment
Open

ImageUploader does not work with useState variable #141

elliotBraem opened this issue Oct 13, 2023 · 1 comment

Comments

@elliotBraem
Copy link
Contributor

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={} ?

@evgenykuzyakov
Copy link
Contributor

I think IpfsImageUpload should be deprecated. Better to reimplement this logic in a widget. It doesn't have anything that a Widget can't do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants