diff --git a/src/modules/core/hoc/withPropsFrom.tsx b/src/modules/core/hoc/withPropsFrom.tsx index e14ed295..76e9a78a 100644 --- a/src/modules/core/hoc/withPropsFrom.tsx +++ b/src/modules/core/hoc/withPropsFrom.tsx @@ -6,9 +6,9 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import { ComponentType, forwardRef, memo } from 'react'; +import { ComponentType, memo, forwardRef } from 'react'; -type PropsSourceCreator = () => T; +type PropsSourceCreator> = (props: Props) => T; export const withPropsFrom = < ComponentProps extends Record, @@ -16,12 +16,17 @@ export const withPropsFrom = < SourcePropKeys extends keyof (ComponentProps | MergeObjectsArray), >( Component: ComponentType, - propsSources: { [K in keyof SourceProps]: PropsSourceCreator }, + propsSources: { + [K in keyof SourceProps]: PropsSourceCreator>; + }, sourcePropKeys: SourcePropKeys[], ) => memo( forwardRef>((props, ref) => { - const sourceProps = propsSources.reduce((acc, propsSource) => ({ ...acc, ...propsSource() }), {}); + const sourceProps = propsSources.reduce( + (acc, propsSource) => ({ ...acc, ...propsSource(props as Omit) }), + {}, + ); const selectedProps = Object.fromEntries( Object.entries(sourceProps).filter(([key]) => sourcePropKeys.includes(key as SourcePropKeys)),