For the past few days, I have been trying to understand best practices for better performance for react applications. I read that inline styles are not as efficient as CSS class-based styles for obvious reasons but I wanted to know how much they actually differ when compared to:
- Inline styles with variables
example:
<div id='myDiv' style={ "--myColor": dynamic_color }></div>`
CSS:
#myDiv {
color: var(--myColor)
}
- Element References
example:
divRef.current.style.background = dynamic_background
Considering performance, which one of them is the best and which one should be used in what cases. Also, is there any other way that might be more suitable for dynamic styles.
Thanks


