4 ms·
I noticed there are components for all the standard HTML typography like <kbd> is <Kbd> and such. Is there a perf hit in wrapping everything in a react compone
by netghost 10y ago
I noticed there are components for all the standard HTML typography like <kbd> is <Kbd> and such. Is there a perf hit in wrapping everything in a react component? Any particular reason to do this?
- exogen 10y agoNot sure about the perf difference between DOM elements and component elements, but the primary reason would be: let's say later on you decide each <kbd> should have a className, or a little tooltip helper, or a title attribute, or some ARIA role or something. Since you can't modify the built-in DOM elements, you'd have to find each instance where you used <kbd> throughout the codebase. If they're wrapped, you can just modify the <Kbd> wrapper in one place and the new output is rendered everywhere.
- thejameskyle 10y agoThis is exactly it. Also if we ever choose to use React Native (cough), it would be good not to have hard coded DOM elements. I haven't tested the performance heavily but I'm not really concerned about it.