I'm wondering what the best way is to NOT apply styles as one of the results in ternary operator for inline styles, specifically whether its better to pass undefined or {}, as in:
<div style={shouldApplyStyle ? {background: 'black'} : undefined />
OR
<div style={shouldApplyStyle ? {background: 'black'} : {}/>
I know that generally speaking these two function the same, but I'm wondering if passing an empty object would cause unnecessary re-renders because in javascript {} != {}
so it would interpret the style prop as having changed every time.
This was pointed out as a possibility in a comment on this answer: https://stackoverflow.com/a/58339902/4440124
In addition to knowing whether passing an empty prop will cause additional rerenders, I'd also like to know if there are any other performance implications or dangers with using one over the other. Thanks!