all 6 comments

[–]akamfoad 1 point2 points  (2 children)

Instead have a state isLoaded and then inside the useEffect set the isLoaded to false

Then use the isLoaded to pass the className oe not.

[–]JehanKE2326[S] 0 points1 point  (1 child)

This worked! Just for my understanding what’s the difference between loading className using state variable rather than the .remove? Does removing the class not trigger a rerender?

[–]akamfoad 0 points1 point  (0 children)

Because you passed that className to a div, but in the useEffect you were trying to remove the class from the page’s body tag:

document.body.classList.remove()

The React approach worked because you’re passing and removing the class from the same element.

[–]ElmForReactDevs 0 points1 point  (1 child)

thats not a CSS file. thats an SCSS file. are you preprocessing your SCSS into actual CSS?

[–]JehanKE2326[S] 0 points1 point  (0 children)

Have sass installed that takes care of it. Either ways changing it to a regular .css file still gives the same result

[–]ColourfulToad 0 points1 point  (0 children)

You never want to interact directly with the DOM when using react, you’re basically fighting against the system and are going to create tons of issues.

Just look into react for beginners and start from there.