mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Create higher-order-components.md (#9976)
This commit is contained in:
@@ -177,10 +177,10 @@ Resist the temptation to modify a component's prototype (or otherwise mutate it)
|
||||
|
||||
```js
|
||||
function logProps(InputComponent) {
|
||||
InputComponent.prototype.componentWillReceiveProps(nextProps) {
|
||||
InputComponent.prototype.componentWillReceiveProps = function(nextProps) {
|
||||
console.log('Current props: ', this.props);
|
||||
console.log('Next props: ', nextProps);
|
||||
}
|
||||
};
|
||||
// The fact that we're returning the original input is a hint that it has
|
||||
// been mutated.
|
||||
return InputComponent;
|
||||
|
||||
Reference in New Issue
Block a user