How to render a react component in sweetalert2 innerhtml?

165 Views Asked by At

This is my code which i want render CarReport component in a sweetalert modal. <CarReport /> is just a simple form.

Swal.fire({
        title: "..."
        html: <CarReport />, //How to write this line?
        confirmButtonText: "Check",
        preConfirm: () => {
            //api request
        },
      });

Currently this code opens the modal but shows [object object] in body of the modal.

1

There are 1 best solutions below

0
Montserrat Delgado On

SweetAlert2 does not support react components. For that it requires using

sweetalert2-react-content