Skip to content

Commit

Permalink
Memorize widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
vin0401 committed Feb 28, 2024
1 parent 1cd467f commit e2dc682
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions assets/js/src/modules/widget-manager/utils/widget-registry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type ComponentType } from 'react'
import { type ComponentType, memo } from 'react'

export interface Widget {
name: string
Expand All @@ -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 => {
Expand Down

0 comments on commit e2dc682

Please sign in to comment.