import React, { useContext } from 'react'; type DataScrollerContextValue = { data: any; }; export const DataScrollerContext = React.createContext< DataScrollerContextValue >({ data: {}, }); type ComponentProps = { data: Data; children: React.ReactNode; }; export function DataScrollerContextProvider(props: ComponentProps) { return ( {props.children} ); } function defaultMapContextDataValueToProps( props: Props, data: Data, ): any { return { ...props, data }; } type MapContextValueToProps = ( props: OuterProps, data: Data, ) => InnerProps; export function getRowData( mapContextValueToProps?: MapContextValueToProps, ) { return function(Component: React.FC) { const MemoizedComponent = (React.memo(Component) as any) as React.FC< InnerProps >; return function

(props: P) { const contextValue = useContext(DataScrollerContext); const propsWithState = mapContextValueToProps ? mapContextValueToProps(props, contextValue.data) : (defaultMapContextDataValueToProps( props, contextValue.data, ) as InnerProps); return ; }; }; }