Skip to content

Instantly share code, notes, and snippets.

@danlourenco
Created February 7, 2020 17:55
Show Gist options
  • Select an option

  • Save danlourenco/642df91c88fbfc8b44fd2658097c755d to your computer and use it in GitHub Desktop.

Select an option

Save danlourenco/642df91c88fbfc8b44fd2658097c755d to your computer and use it in GitHub Desktop.

Revisions

  1. danlourenco created this gist Feb 7, 2020.
    19 changes: 19 additions & 0 deletions React HOC
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    const withHOC = (WrappedComponent) => {

    return class WithHoc extends React.Component {

    // custom methods to augment wrapped component

    render() {
    return <WrappedComponent {...this.props} />
    }
    }
    }



    // usage

    const AppWithHoc = withHOC(App);

    <AppWithHoc />