djorg83 / react-bootstrap-sweetalert

A React implementation of SweetAlert
https://djorg83.github.io/react-bootstrap-sweetalert/
MIT License
252 stars 55 forks source link

onCancel not working. #69

Closed lucasmrl closed 4 years ago

lucasmrl commented 4 years ago

Hi there! I have a component that will render the alert. If I click outside the alert, I got this error: "TypeError: Cannot read property 'onCancel' of undefined"

The code for the alert:

    <SweetAlert
      title=""
      onConfirm=""
      showConfirm="false"
      showCloseButton="true"
      onCancel={this.onCancel}
      customButtons={
        <React.Fragment>
          <input
            onClick={() => window.location.reload(false)}
            value="Add"
            type="submit"
            disabled="true"
            className="hidden bg-gray-900 text-white flex items-center content-center justify-center rounded-md p-2 w-32 mb-1 cursor-pointer"
          />
        </React.Fragment>
      }
    >
      <div className="">{projectForm}</div>
    </SweetAlert>

This code is inserted on a function component, inside the return method. I also tried:

Thanks in advance!

lucasmrl commented 4 years ago

Not an issue.