'ReactJS form control, display vs if else
I am working on a big form with many branches. I am wondering if there is any performance difference between
<Box display={type == type.RatioBased ? "none" : "flex"}>
and
{type == type.RatioBased ? "" : (<Box >......</Box>)}
Any suggestions helps
Solution 1:[1]
If you used the first choice you will populate the DOM
with an unwanted component and that will lead to a bigger DOM
and can slow the processing of the DOM
.
In the second choice, the component Box
will get removed from the DOM
. It’s better to go with the second choice.
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 | Soufiane Boutahlil |