-
-
Save phidn/6295a89056c61408c4de515e38ef33d2 to your computer and use it in GitHub Desktop.
Revisions
-
sorenlouv revised this gist
Sep 16, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -25,4 +25,4 @@ export default function withPropsChecker(WrappedComponent) { } // Usage withPropsChecker(MyComponent) -
sorenlouv revised this gist
Sep 16, 2017 . 1 changed file with 3 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,3 @@ import React, { Component } from 'react'; export default function withPropsChecker(WrappedComponent) { @@ -29,3 +23,6 @@ export default function withPropsChecker(WrappedComponent) { } }; } // Usage withPropsChecker(myComponent) -
sorenlouv revised this gist
Sep 16, 2017 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,8 @@ // Usage withPropsChecker(myComponent) // Implementation import React, { Component } from 'react'; -
sorenlouv revised this gist
Sep 16, 2017 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,8 @@ // Usage withPropsChecker(myComponent import React, { Component } from 'react'; export default function withPropsChecker(WrappedComponent) { -
sorenlouv created this gist
Sep 16, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ import React, { Component } from 'react'; export default function withPropsChecker(WrappedComponent) { return class PropsChecker extends Component { componentWillReceiveProps(nextProps) { Object.keys(nextProps) .filter(key => { return nextProps[key] !== this.props[key]; }) .map(key => { console.log( 'changed property:', key, 'from', this.props[key], 'to', nextProps[key] ); }); } render() { return <WrappedComponent {...this.props} />; } }; }