Im making a modal in my React project that requires a class to be added to the body when the modal is open and removed when it is closed.
I could do this the old jQuery
Like what @brian mentioned, try having a top-level container component that wraps around your other components. (assuming you're not using redux in your app)
In this top-level component:
modalOpen
) to toggle the CSS classhandleOpenModal
& handleCloseModal
) to modify the boolean state.
component