reflective-bind
Advanced tools
Comparing version 0.2.2 to 0.2.3
@@ -379,2 +379,3 @@ /** | ||
!isNonComputedNestedProperty(identifierPath) && | ||
!isNonComputedObjectKey(identifierPath) && | ||
!hasBindingInScope(identifierPath, limitScope) | ||
@@ -394,2 +395,11 @@ ); | ||
function isNonComputedObjectKey(identifierPath) { | ||
const parentNode = identifierPath.parentPath.node; | ||
return ( | ||
t.isProperty(parentNode) && | ||
!parentNode.computed && | ||
parentNode.key === identifierPath.node | ||
); | ||
} | ||
/** | ||
@@ -396,0 +406,0 @@ * Returns true iff the identifier is bound within limitScope. |
@@ -7,2 +7,5 @@ # Reflective Bind Change Log | ||
## 0.2.3 | ||
* Don't hoist handle non-computed object property identifiers | ||
## 0.2.2 | ||
@@ -9,0 +12,0 @@ * Upgrade to babel 7 |
{ | ||
"name": "reflective-bind", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Eliminate wasteful re-rendering in React components caused by inline functions", | ||
@@ -5,0 +5,0 @@ "author": "Dounan Shi", |
@@ -46,14 +46,13 @@ [![Build Status](https://travis-ci.org/flexport/reflective-bind.svg?branch=master)](https://travis-ci.org/flexport/reflective-bind) | ||
If you’re already using `React.PureComponent` and want to avoid updating all of your components, consider monkey patching `shouldComponentUpdate` 🙊 | ||
Alternatively, subclass `React.Component` and override `shouldComponentUpdate`. Then extend your custom component when you want a pure component. | ||
```js | ||
import React from "react"; | ||
import * as React from "react"; | ||
import {shouldComponentUpdate} from "reflective-bind"; | ||
React.PureComponent.prototype.shouldComponentUpdate = function( | ||
nextProps, | ||
nextState | ||
) { | ||
return shouldComponentUpdate(this, nextProps, nextState); | ||
}; | ||
export default class CustomPureComponent extends React.Component { | ||
shouldComponentUpdate(nextProps, nextState) { | ||
return shouldComponentUpdate(this, nextProps, nextState); | ||
} | ||
} | ||
``` | ||
@@ -60,0 +59,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56267
1072
259