Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Created April 25, 2021 04:41
Show Gist options
  • Save sabesansathananthan/026e4a284f119300f0f506dd5c729fe6 to your computer and use it in GitHub Desktop.
Save sabesansathananthan/026e4a284f119300f0f506dd5c729fe6 to your computer and use it in GitHub Desktop.
How React Components Are Reused
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