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 :: js check if all array values are the same 
Javascript :: javascript moment 
Javascript :: ternary operator jquery 
Javascript :: Find duplicate or repeat elements in js array 
Javascript :: js socket.emit 
Javascript :: .foreach in javascript 
Javascript :: method chaining in javascript 
Javascript :: mongoose find multiple conditions 
Javascript :: tableau js 
Javascript :: array index javascript show only first 2 elements 
Javascript :: check if s3 bucket exists in lambda 
Javascript :: @click vue target 
Javascript :: Material-ui Accessible icon 
Javascript :: javascript press tab key 
Javascript :: svg to png base64 javascript 
Javascript :: javascript deconstruct object 
Javascript :: dynamically add/remove rows in html table using javascript 
Javascript :: multiple export in react 
Javascript :: scroll for sticky 
Javascript :: javascript create json object from array 
Javascript :: html get form elements 
Javascript :: get the length of an object vuejs 
Javascript :: js string to boolean 
Javascript :: how to sho the active navigation ling using javascript 
Javascript :: inject js on button click chrome extension 
Javascript :: javascript prevent iframe interaction 
Javascript :: requirejs example 
Javascript :: angular chart js 
Javascript :: convert int to string in angular 
Javascript :: How to blacklist words with discord.js 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =