I'm a little confused about the display: none
property. Many articles ob the internet says that with display property set to none an element is not in the DOM tree. And that's the difference from opacity: 0
and visibility: hidden
which won't remove an element from the DOM and just make it invisible.
From https://stackoverflow.com/a/4718378/20395932
Because display: none actually removes the elements from the DOM. visibility: hidden merely makes them invisible, but they're still there.
From https://blog.kevinchisholm.com/css/visibility-hidden-vs-display-none/
This is an important detail because with display:none, you are effectively removing the element from the DOM.
Also I read that
The browser will not response to any events of element which uses either display: none or visibility: hidden.
But in React I set a ref to an element, set it's display porperty to none... and I still see that element in DOM in dev tools. Also I can call on-click handlers of this element via the ref.
Also I don't understand how display: none
can remove any element from the DOM if it's just a CSS property and can't realy manipulate DOM.
As far as I understand the element with display: none
is still in the DOM but it's just not rendered. But what about responsing to events?