score:0

You can create a flag and if the flag is false/true then only perform that action. something as simple as this

 useEffect(() => {
   if (something) {
    MapboxGL.setTelemetryEnabled(false);
    setSomething(false) 
    }
  });

or if you only need hook once, you can do what Matt have suggested

useEffect(() => {
   MapboxGL.setTelemetryEnabled(false);
}, []);

score:3

You need to add a dependency array for it to know when to recall this hook. An empty dep array will only call it once aka "on mount". And if you don't provide a dep array then it will just be called on every re-render.

useEffect(() => {
   MapboxGL.setTelemetryEnabled(false);
}, []);

Related Query

More Query from same tag