From e2dc68288d7991b65adf44d2a850f680bc721b66 Mon Sep 17 00:00:00 2001 From: vin0401 Date: Wed, 28 Feb 2024 12:12:29 +0100 Subject: [PATCH] Memorize widgets --- .../src/modules/widget-manager/utils/widget-registry.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/assets/js/src/modules/widget-manager/utils/widget-registry.ts b/assets/js/src/modules/widget-manager/utils/widget-registry.ts index 073feed50..3ba91d7b7 100644 --- a/assets/js/src/modules/widget-manager/utils/widget-registry.ts +++ b/assets/js/src/modules/widget-manager/utils/widget-registry.ts @@ -1,4 +1,4 @@ -import { type ComponentType } from 'react' +import { type ComponentType, memo } from 'react' export interface Widget { name: string @@ -8,7 +8,12 @@ export interface Widget { export const widgets: Widget[] = [] export const registerWidget = (widget: Widget): void => { - widgets.push(widget) + const newWidget = { + ...widget, + component: memo(widget.component) + } + + widgets.push(newWidget) } export const getWidget = (name: string): Widget | undefined => {