I do wonder why you're no longer adding a class to an element in your examples. I might be wrong, but your examples don't answer the question in your first paragraph: how do you add a class (via classList.add) to an element that hasn't yet been found by React?
Yeah, I didn't use an example to answer that question (sorry). However, I think what I wanted to say was that if we wanted to add some code that depended on the component's render, useEffect would be the right place to add that code. Because it gets called after all the elements are painted on the page. :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I do wonder why you're no longer adding a class to an element in your examples. I might be wrong, but your examples don't answer the question in your first paragraph: how do you add a class (via classList.add) to an element that hasn't yet been found by React?
Yeah, I didn't use an example to answer that question (sorry). However, I think what I wanted to say was that if we wanted to add some code that depended on the component's render,
useEffect
would be the right place to add that code. Because it gets called after all the elements are painted on the page. :)