djorg83 / react-bootstrap-sweetalert

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

Sweetalert not working on nodejs 10.13 #37

Closed namnguyen2091 closed 5 years ago

namnguyen2091 commented 5 years ago

I try to follow this link https://stackoverflow.com/questions/41006087/add-sweet-alert-popup-to-button-in-react-component/41006372#41006372 but I got an error Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. Check your code at Company.js:15. I dont know why what happened, please help me how to use this?

djorg83 commented 5 years ago

Im going to need more information to debug this. I dont know what Company.js is. This project contains no such file.

namnguyen2091 commented 5 years ago

Thanks for your reply. I try to follow link above and it's not working so I try other way, maybe I'm new user so I dont know how it works. This is my code changed and its working fine.

<button onClick={() => this.showPopupConfirm('Save changes for client', 'Are you sure?', () => this.handleDeleteClick, 'custom') }>Delete</button>
showPopupConfirm(title, message, callBack, style) {
    this.setState({
      alert: (
          <SweetAlert
              info
              showCancel
              confirmBtnText = "Yes"
              cancelBtnText = "No"
              confirmBtnBsStyle="danger"
              cancelBtnBsStyle = "primary"
              title = {title}
              onConfirm = {callBack()}
              onCancel = {this.hideAlert}
          >
            {message}
          </SweetAlert>
      )
    });
  }

Thanks for your awesome component.