JSFiddle - React, Tailwind, and code Playground

HTML

<a href="#">Click here</a>

<div></div>

CSS

div {
    width:200px;
    height:200px;
    display:none;
    background:#000;
}
a, div {
    float:left;
}

JavaScript

$('a').click(function (e) {
    e.preventDefault();
    $('div').show();
});

$(document).mouseup(function (e) {
    var container = $("div");
    if (!container.is(e.target) && container.has(e.target).length === 0) {
        container.hide();
    }
});