mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
XYCanvas: useMemo() for className gen (#37513)
This commit is contained in:
parent
1fe3452886
commit
27b94139ed
@ -1,5 +1,5 @@
|
|||||||
import { usePlotContext } from '../context';
|
import { usePlotContext } from '../context';
|
||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
|
|
||||||
interface XYCanvasProps {}
|
interface XYCanvasProps {}
|
||||||
@ -16,16 +16,14 @@ export const XYCanvas: React.FC<XYCanvasProps> = ({ children }) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
const className = useMemo(() => {
|
||||||
<div
|
return css`
|
||||||
className={css`
|
position: absolute;
|
||||||
position: absolute;
|
overflow: visible;
|
||||||
overflow: visible;
|
left: ${plotInstance.bbox.left / window.devicePixelRatio}px;
|
||||||
left: ${plotInstance.bbox.left / window.devicePixelRatio}px;
|
top: ${plotInstance.bbox.top / window.devicePixelRatio}px;
|
||||||
top: ${plotInstance.bbox.top / window.devicePixelRatio}px;
|
`;
|
||||||
`}
|
}, [plotInstance.bbox.left, plotInstance.bbox.top]);
|
||||||
>
|
|
||||||
{children}
|
return <div className={className}>{children}</div>;
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user