Could you share your point of view about the best approach to change element`s style dynamicaly. I am refactoring data table with virtual scroll component, where I need to change the first and last lines' height dynamicaly. Now I change it by specifying element's inline styles like that:
<tr style={{ height: `${scroll.firstRowHeight}px` }}></tr>
Is that OK or it is better to select element with useRef or document.querySelector first and then change the height?
I am asking this question because I've come accross different opinions:
useRef
and document
selectors are adding changes to the real DOM and not the virtual DOM. Changes to virtual DOM is preferred since react knows about it and applies changes to the real DOM accordingly (See reconciliation in React)