'How to hide Bootstrap 5 modal programatically in react?

How to hide Bootstrap 5 modal programmatically in React?

I have tried this:

const myModal = document.getElementById("dis-approve-modal");
myModal.hide();

but it says "hide is not a function".



Solution 1:[1]

i'm sure this not the right way to do it -via HTML element properties-

but if you want to do it this way try

myModal.hidden = true;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Omar Mohamed