I know that display: none
removes the element from the page while visibility: hidden
hides the element but preserves the space.
My question is, is it a good idea to use the two styles together on an element and if so, what is the priority order of the two when used together?
My use case is like so:
When
shouldRemoveElement = true
, Irrespective ofshouldHideElement
the div should be removed from the page.When
shouldRemoveElement = false
, the div should respect thevisibility
style based on theshouldHideElement
value.
While this works as expected I'm wondering if it could cause any unexpected side effects.
sample code:
<div className="field-container count-field"
style={{ display: shouldRemoveElement ? 'none' : true, visibility: shouldHideElement ? 'hidden' : 'visible' }}>
<customComponent>..</customComponent>
</div>