'How do I convert this querySelector to react code?

So I have a three.js class that uses querySelector to take the DOM element and implements the three.js part. It was working fine in HTML and JS but not working in react at all. Through console debug, I found out that querySelector is the problem. So how do I fix it?

enter image description here enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source