Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

HOC Generic using React Typescript

import React, {ComponentType} from 'react';

export interface AdditionalProps {
    additionalProp: string;
}

export function hoc<T extends AdditionalProps>(WrappedComponent: ComponentType<T>) {
    const additionalProp = //...
          
          return (hocprops:T)=>{
            
            return (
              <WrappedComponent
              {...hocprops}
              />
            )
          }
    
}
 
PREVIOUS NEXT
Tagged: #HOC #Generic #React #Typescript
ADD COMMENT
Topic
Name
4+7 =