mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -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 React from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import { css } from '@emotion/css';
|
||||
|
||||
interface XYCanvasProps {}
|
||||
@ -16,16 +16,14 @@ export const XYCanvas: React.FC<XYCanvasProps> = ({ children }) => {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={css`
|
||||
position: absolute;
|
||||
overflow: visible;
|
||||
left: ${plotInstance.bbox.left / window.devicePixelRatio}px;
|
||||
top: ${plotInstance.bbox.top / window.devicePixelRatio}px;
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
const className = useMemo(() => {
|
||||
return css`
|
||||
position: absolute;
|
||||
overflow: visible;
|
||||
left: ${plotInstance.bbox.left / window.devicePixelRatio}px;
|
||||
top: ${plotInstance.bbox.top / window.devicePixelRatio}px;
|
||||
`;
|
||||
}, [plotInstance.bbox.left, plotInstance.bbox.top]);
|
||||
|
||||
return <div className={className}>{children}</div>;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user