I'm calling dispose() and setting it to null afterwards, in the useEffect's clean up callback function. Is this a good practice doing both calling dispose() there explicitly and null-it to both: prevent further usage and tell the JS' GC to collect it.
useEffect(() => {
let markersDispo: monaco.IDisposable | null =
monaco.editor.onDidChangeMarkers(handleMarketsChanges);
return () => {
markersDispo!.dispose();
markersDispo = null;
}, [foo]);