sweetalert2 / sweetalert2-react-content

Official SweetAlert2 enhancer adding support for React elements as content
MIT License
689 stars 47 forks source link

didOpen and willOpen (mixin) are not been fired anymore in 5x versions #238

Closed zyc closed 1 year ago

zyc commented 1 year ago

After upgrading to 5x versions, the didOpen and willOpen callbacks are not fired anymore using Swap.mixin like this:

const willOpen = () => { console.log("I'm lost") };

const MySwal = withReactContent(
      Swal.mixin({
        willOpen,
      })
    );

MySwal.fire({ title: <p>Hello World</p> })

It was working fine in 4x versions.

limonte commented 1 year ago

This usage is undocumented and I'm not sure for now how/if it should be fixed.

This will work:

const willOpen = () => {
  console.log("I'm not lost")
}

const MySwal = withReactContent(Swal)

const MySwalMixin = MySwal.mixin({
  willOpen,
})

MySwalMixin.fire({ title: <p>Hello World</p> })
zyc commented 1 year ago

This usage is undocumented and I'm not sure for now how/if it should be fixed.

This will work:

const willOpen = () => {
  console.log("I'm not lost")
}

const MySwal = withReactContent(Swal)

const MySwalMixin = MySwal.mixin({
  willOpen,
})

MySwalMixin.fire({ title: <p>Hello World</p> })

Thanks! It worked.