Created
December 11, 2018 17:47
-
-
Save fjcaetano/26986ee2de0c8f3cc803f08b263d5d96 to your computer and use it in GitHub Desktop.
Pure React component HOC in Typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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