Created
April 25, 2021 04:36
-
-
Save sabesansathananthan/4222427abdc6007ba470a9f8d5fd6152 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(InputComponent) { | |
InputComponent.prototype.componentDidUpdate = function(prevProps) { | |
console.log("Current props: ", this.props); | |
console.log("Previous props: ", prevProps); | |
}; | |
// Return the original input component, which has been modified. | |
return InputComponent; | |
} | |
// Every time logProps is called, the enhanced component will have log output. | |
const EnhancedComponent = logProps(InputComponent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment