Created
April 25, 2021 04:41
-
-
Save sabesansathananthan/026e4a284f119300f0f506dd5c729fe6 to your computer and use it in GitHub Desktop.
How React Components Are Reused
This file contains hidden or 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
function logProps(WrappedComponent) { | |
return class extends React.Component { | |
componentDidUpdate(prevProps) { | |
console.log("Current props: ", this.props); | |
console.log("Previous props: ", prevProps); | |
} | |
render() { | |
// Wrap the input component in a container without modifying it, Nice! | |
return <WrappedComponent {...this.props} />; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment