<commit_before>import * as React from 'react';

import { RouteComponentProps } from '.';
import { State } from '../../reducers';
import { packageKey, PackageDocumentationRequest } from '../../util';

export interface PackageRequestInjectedProps {
    pkgRequestKey: PackageKey;
    pkgRequestStatus: PackageDocumentationRequest;
}

/** Takes the route parameters `PackageKey`, and injects `PackageRequestInjectedProps` */
export const withPackageRequest =
    <TProps extends {}>(Component: React.ComponentType<TProps & PackageRequestInjectedProps>) =>
    (props: TProps & State & RouteComponentProps<PackageKey>) => {
        const request = props.packageDoc.packageDocumentationRequests[packageKey(props.match.params)];
        return <Component {...props} pkgRequestStatus={request} pkgRequestKey={props.match.params}/>;
    };<commit_msg>Change withPackageRequest to use Hoc.<commit_after>import * as React from 'react';

import { RouteComponentProps, Hoc, ExtendingHoc } from '.';
import { State } from '../../reducers';
import { packageKey, PackageDocumentationRequest } from '../../util';

export interface PackageRequestInjectedProps {
    pkgRequestKey: PackageKey;
    pkgRequestStatus: PackageDocumentationRequest;
}
export type PackageRequestRequiredProps = State & RouteComponentProps<PackageKey>;

function createWithPackageRequest<TProps>(): Hoc<TProps & PackageRequestRequiredProps, TProps & PackageRequestInjectedProps> {
    return Component => props => {
        const request = props.packageDoc.packageDocumentationRequests[packageKey(props.match.params)];
        return <Component {...props} pkgRequestStatus={request} pkgRequestKey={props.match.params}/>;
    };
}

/** Takes the route parameters `PackageKey`, and injects `PackageRequestInjectedProps` */
export const withPackageRequest : ExtendingHoc<PackageRequestInjectedProps, PackageRequestRequiredProps> = createWithPackageRequest();
{'fraction_non_alphanumeric': 0.11442006269592477, 'fraction_numerical': 0.0, 'mean_word_length': 5.603448275862069, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7478394', 'n_tokens_mistral': 490, 'n_tokens_neox': 485, 'n_words': 118}