Skip to content

Instantly share code, notes, and snippets.

@fjcaetano
Created December 11, 2018 17:47
Show Gist options
  • Save fjcaetano/26986ee2de0c8f3cc803f08b263d5d96 to your computer and use it in GitHub Desktop.
Save fjcaetano/26986ee2de0c8f3cc803f08b263d5d96 to your computer and use it in GitHub Desktop.
Pure React component HOC in Typescript
import React from 'react';
const withPure = <P extends any>(
WrappedComponent: React.ComponentType<P>,
): React.ComponentClass<P> => {
class Purified extends React.PureComponent<P> {
render() {
return <WrappedComponent {...this.props} />;
}
}
return Purified;
};
export default withPure;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment