Dat.gui shows on other pages too

Hello , due to lack of time i implemented three js in react the primitive way, set route for it and works fine untill i switch to another link.

const Modeling = () => {
const mountRef = useRef(null);
useEffect(() => {
three.js codee
return (

<div ref = {mountRef}>
   <div id = "webgl">


It shows the dat.gui on other pages too.
I know the implementation is not perfect but is there any way to avoid this?