Skip to content

Instantly share code, notes, and snippets.

@deniztetik
Created July 8, 2018 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deniztetik/b25b334e23d31486c3e5cdd76e26abcb to your computer and use it in GitHub Desktop.
Save deniztetik/b25b334e23d31486c3e5cdd76e26abcb to your computer and use it in GitHub Desktop.
function logProps(WrappedComponent) {
return class extends React.Component {
componentDidUpdate(prevProps) {
console.log('Previous props: ', prevProps);
console.log('Current props: ', this.props);
}
render() {
// Wraps the input component in a container, without mutating it. Good!
return <WrappedComponent {...this.props} />;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment