Answers for "how-to-open-sweetalert-popup-on-button-click-in-reactjs"

0

how-to-open-sweetalert-popup-on-button-click-in-reactjs

npm install sweetalert2-react

//////////////////////////////////////////////////////////

import React from 'react';
import './App.css';
import Swal from 'sweetalert2'


class App extends React.Component {
 
  opensweetalert = () =>
  {
    Swal.fire({
      title: 'Therichpost',
      text: "Hello",
      type: 'success', 
    }



  render() {
   
    return (
<div className="maincontainer">
  
  <h1>Reactjs</h1>
  
  <button onClick={this.opensweetalert}>Open Success Sweetalert Popup</button>
  
</div>
)
};
}
export default App;
Posted by: Guest on June-24-2021

Code answers related to "how-to-open-sweetalert-popup-on-button-click-in-reactjs"

Browse Popular Code Answers by Language