Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ALERTIFY JS in React?

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'); 
  });
}
like image 348
Sultan Aslam Avatar asked Sep 02 '18 14:09

Sultan Aslam


2 Answers

Need to add the css file too. Problem Solved.

import 'alertifyjs/build/css/alertify.css';
like image 161
Sultan Aslam Avatar answered Oct 23 '22 09:10

Sultan Aslam


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

like image 43
SohanLal Saini Avatar answered Oct 23 '22 07:10

SohanLal Saini