diff --git a/src/modules/core/hoc/withPropsFrom.tsx b/src/modules/core/hoc/withPropsFrom.tsx index 0dcb69a2..e14ed295 100644 --- a/src/modules/core/hoc/withPropsFrom.tsx +++ b/src/modules/core/hoc/withPropsFrom.tsx @@ -6,7 +6,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { ComponentType, forwardRef } from 'react'; +import { ComponentType, forwardRef, memo } from 'react'; type PropsSourceCreator = () => T; @@ -19,14 +19,16 @@ export const withPropsFrom = < propsSources: { [K in keyof SourceProps]: PropsSourceCreator }, sourcePropKeys: SourcePropKeys[], ) => - forwardRef>((props, ref) => { - const sourceProps = propsSources.reduce((acc, propsSource) => ({ ...acc, ...propsSource() }), {}); + memo( + forwardRef>((props, ref) => { + const sourceProps = propsSources.reduce((acc, propsSource) => ({ ...acc, ...propsSource() }), {}); - const selectedProps = Object.fromEntries( - Object.entries(sourceProps).filter(([key]) => sourcePropKeys.includes(key as SourcePropKeys)), - ) as Pick, SourcePropKeys>; + const selectedProps = Object.fromEntries( + Object.entries(sourceProps).filter(([key]) => sourcePropKeys.includes(key as SourcePropKeys)), + ) as Pick, SourcePropKeys>; - const combinedProps = { ...props, ...selectedProps } as unknown as ComponentProps; + const combinedProps = { ...props, ...selectedProps } as unknown as ComponentProps; - return ; - }); + return ; + }), + );