unlayer / react-email-editor

Drag-n-Drop Email Editor Component for React.js

Home Page:https://unlayer.com/embed

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error while trying to registerCallback

M0hammedImran opened this issue · comments

When I try to registerCallback for selectImage I see the following error on the UI.
Screenshot from 2023-11-23 13-11-51

This is the code used to registerCallback

editor.registerCallback("selectImage", (file, done) => {
  this.setState({ openImageSelectionModal: true });
  this.done = done;
});

And when image is selected, I call done callback

this.done({ url: data });

After calling done things seem to work as usual.

Thanks for reporting @M0hammedImran. While that is not fixed, you can use this workaround:

unlayer.registerCallback("selectImage", async (file) => {
  const thiss = this;

  return new Promise((resolve) => {
    thiss.done = resolve;
  });
});

Thanks for reporting @M0hammedImran. While that is not fixed, you can use this workaround:

unlayer.registerCallback("selectImage", async (file) => {
  const thiss = this;

  return new Promise((resolve) => {
    thiss.done = resolve;
  });
});

Thanks @brunolemos, this worked for me.

@M0hammedImran we have released a fix. please revert back to your original code instead of the workaround. thanks!