We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b877fdc commit 0be1a7aCopy full SHA for 0be1a7a
src/components/FAB/utils.ts
@@ -436,13 +436,17 @@ export const getExtendedFabStyle = ({
436
return isV3 ? v3Extended : extended;
437
};
438
439
+let cachedContext: CanvasRenderingContext2D | null = null;
440
+
441
const getCanvasContext = () => {
- const fragment = document.createDocumentFragment();
- const canvas = document.createElement('canvas');
442
+ if (cachedContext) {
443
+ return cachedContext;
444
+ }
445
- fragment.appendChild(canvas);
446
+ const canvas = document.createElement('canvas');
447
+ cachedContext = canvas.getContext('2d');
448
- return canvas.getContext('2d');
449
450
451
452
export const getLabelSizeWeb = (ref: MutableRefObject<HTMLElement | null>) => {
0 commit comments