How to implement document.getElementById in Gatsby(React)

I’m trying to write a function in my Gatsby project.
In normal javascript projects I would use document.getElementById to manipulate an element from the DOM, but how does that way of manipulation work in Gatsby? Can’t seem to find any information online.

  • When I try to do it in the normal javascript way, I get a warning that says my variable is assigned a value, but it’s never used. Any way to fix this?

88 thoughts on “How to implement document.getElementById in Gatsby(React)”

Leave a Comment