mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
revert: change to events canvas (#38023)
This commit is contained in:
parent
49b129b110
commit
7b813c81ac
@ -20,7 +20,7 @@ const addDataSource = () => {
|
||||
});
|
||||
};
|
||||
|
||||
describe.skip('Exemplars', () => {
|
||||
describe('Exemplars', () => {
|
||||
beforeEach(() => {
|
||||
e2e.flows.login('admin', 'admin');
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { DataFrame, DataFrameFieldIndex } from '@grafana/data';
|
||||
import React, { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
||||
import React, { useLayoutEffect, useMemo, useState } from 'react';
|
||||
import { usePlotContext } from '../context';
|
||||
import { Marker } from './Marker';
|
||||
import { XYCanvas } from './XYCanvas';
|
||||
@ -21,25 +21,13 @@ export function EventsCanvas({ id, events, renderEventMarker, mapEventToXYCoords
|
||||
// render token required to re-render annotation markers. Rendering lines happens in uPlot and the props do not change
|
||||
// so we need to force the re-render when the draw hook was performed by uPlot
|
||||
const [renderToken, setRenderToken] = useState(0);
|
||||
const isMounted = useRef(false);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (isMounted.current === false) {
|
||||
return;
|
||||
}
|
||||
config.addHook('draw', () => {
|
||||
setRenderToken((s) => s + 1);
|
||||
});
|
||||
}, [config, setRenderToken]);
|
||||
|
||||
// clean up action to avoid memory leak
|
||||
useEffect(() => {
|
||||
isMounted.current = true;
|
||||
return () => {
|
||||
isMounted.current = false;
|
||||
};
|
||||
}, []);
|
||||
|
||||
const eventMarkers = useMemo(() => {
|
||||
const markers: React.ReactNode[] = [];
|
||||
const plotInstance = plotCtx.plot;
|
||||
|
Loading…
Reference in New Issue
Block a user