react-native-picker-select
Advanced tools
Comparing version 5.2.1 to 5.2.2
@@ -0,1 +1,7 @@ | ||
### v5.2.2 | ||
##### Bugfix | ||
- Fixes unnecessary renders (#129) | ||
### v5.2.1 | ||
@@ -2,0 +8,0 @@ |
{ | ||
"name": "react-native-picker-select", | ||
"version": "5.2.1", | ||
"version": "5.2.2", | ||
"description": "A Picker component for React Native which emulates the native <select> interfaces for each platform", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -113,10 +113,11 @@ import React, { PureComponent } from 'react'; | ||
static getDerivedStateFromProps(nextProps, prevState) { | ||
// update items if items prop changes | ||
const itemsChanged = !isEqual(prevState.items, nextProps.items); | ||
// update selectedItem if value prop is defined and differs from currently selected item | ||
const newItems = RNPickerSelect.handlePlaceholder({ | ||
// update items if items or placeholder prop changes | ||
const items = RNPickerSelect.handlePlaceholder({ | ||
placeholder: nextProps.placeholder, | ||
}).concat(nextProps.items); | ||
const itemsChanged = !isEqual(prevState.items, items); | ||
// update selectedItem if value prop is defined and differs from currently selected item | ||
const { selectedItem, idx } = RNPickerSelect.getSelectedItem({ | ||
items: newItems, | ||
items, | ||
key: nextProps.itemKey, | ||
@@ -132,5 +133,6 @@ value: nextProps.value, | ||
} | ||
return { | ||
items: itemsChanged ? newItems : prevState.items, | ||
selectedItem: selectedItemChanged ? selectedItem : prevState.selectedItem, | ||
...(itemsChanged && { items }), | ||
...(selectedItemChanged && { selectedItem }), | ||
}; | ||
@@ -137,0 +139,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
33152