Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

React alert popup

import { confirmAlert } from 'react-confirm-alert'; // Import
import 'react-confirm-alert/src/react-confirm-alert.css'; // Import css

class App extends React.Component {
  submit = () => {
    confirmAlert({
      title: 'Confirm to submit',
      message: 'Are you sure to do this.',
      buttons: [
        {
          label: 'Yes',
          onClick: () => alert('Click Yes')
        },
        {
          label: 'No',
          onClick: () => alert('Click No')
        }
      ]
    });
  };

  render() {
    return (
      <div className='container'>
        <button onClick={this.submit}>Confirm dialog</button>
      </div>
    );
  }
}
Comment

react js alert popup example

import React from 'react'
import { withAlert } from 'react-alert'

const App = ({ alert }) => (
  <button
    onClick={() => {
      alert.show('Oh look, an alert!')
    }}
  >
    Show Alert
  </button>
)

export default withAlert()(App)
Comment

PREVIOUS NEXT
Code Example
Javascript :: Error [DISALLOWED_INTENTS]: Privileged intent provided is not enabled or whitelisted. 
Javascript :: jquery find tag and class 
Javascript :: this.setstate is not a function 
Javascript :: Capitalize first letter of string on json sending 
Javascript :: js rock paper scissors 
Javascript :: javascript change title 
Javascript :: drupal8 get params from route 
Javascript :: brwoser prompt before reload 
Javascript :: react useid hook 
Javascript :: wordpress ajax trigger code 
Javascript :: Check for a Null or Empty String in JavaScript 
Javascript :: mongoose response to object 
Javascript :: node.js web server 
Javascript :: can we send raw json in get method in flutter 
Javascript :: how reliable is js hasownproperty 
Javascript :: js unique string array 
Javascript :: crud template 
Javascript :: how to get first and last element of array in javascript 
Javascript :: print page using js 
Javascript :: update to node 12 mac 
Javascript :: javascript input 
Javascript :: javascript check if string contains only numbers 
Javascript :: document.addEventListener("backbutton 
Javascript :: how to import a json string from a file in typescript 
Javascript :: node.js log to file 
Javascript :: days in the current month 
Javascript :: how to add eslint to react project 
Javascript :: JS iterate over an array 
Javascript :: what is the function of delete operator in javascript 
Javascript :: event.currenttarget 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =