JSFiddle - React, Tailwind, and code Playground

HTML

<div id="dialog" title="Basic dialog">
  <p>This is the default dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>

JavaScript

var error = 1;
$(document).on('click', '.ui-icon-closethick', function(event){
      if(error == 1){
          alert('error');
          event.preventDefault();
          event.stopPropagation();
          return false;
      } 
})

  $(function() {
    $( "#dialog" ).dialog();
  });