Just diving into React and I'm faced with a challenge - how to update the CSS of a class based on a condition.
let customizeColumn = document.querySelector(".main-table-body");
!expandFilter ? customizeColumn.setAttribute("style", `height:calc(100vh - 345px)`) : customizeColumn.setAttribute("style", `height:calc(100vh - 302px)`);
Currently, I am keeping track of the state of 'expandFilter' and toggling it with a button click.
const [expandFilter, toggleFilter] = useState(false);
However, I'd prefer not to rely on
document.querySelector(".main-table-body")
for accessing the class. Is there an alternative method that doesn't involve directly grabbing the element? Also, I am utilizing Material-UI
, if that offers any solutions.