Answer the question
In order to leave comments, you need to log in
React.js - return null vs display: none?
Which is faster in performance for hiding an element, or ? return null
display : none
Answer the question
In order to leave comments, you need to log in
I think it return null
will make changes to the DOM, or to be more precise, it will remove the element, whereas setting a CSS property or adding a CSS class hide
with a CSS property display : none
will hide the element faster because there is no need to change the DOM.
These are my guesses, and so I'll go look for proof / refutation of my guesses.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question