How to use ALERTIFY JS in React?

Viewed 5008

I'm trying to use ALERTIFYJS in react but its alertify alerts are not working. Below is the code

(window.alert is working fine on my browser)

import alertify from 'alertifyjs';

clickHandle = () => {
  alertify.alert('Alert Title', 'Alert Message!', function(){ 
    alertify.success('Ok'); 
  });
}
2 Answers

Need to add the css file too. Problem Solved.

import 'alertifyjs/build/css/alertify.css';

Yes, You have to add css file as well.

Here is the process for adding css and importing alertify

import alertify from 'alertifyjs';
import 'alertifyjs/build/css/alertify.css';

or

import * as alertify from 'alertifyjs';
import 'alertifyjs/build/css/alertify.css';

Please note I have tested this code on react js 16.13.1 with restify 1.13.1

Related