Skip to content

Commit aa7410a

Browse files
committed
add shouldComponentUpdate
1 parent cb873ca commit aa7410a

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

index.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,21 @@ export default class PickerAndroid extends React.Component{
5252
this.setState(this._stateFromProps(nextProps));
5353
}
5454

55-
shouldComponentUpdate(props, state, context){
55+
shouldComponentUpdate(nextProps, nextState, context){
5656
//JSON.stringify(props) cause error "Converting circular structure to JSON"
57-
return JSON.stringify([state, context]) !== JSON.stringify([this.state, this.context]);
57+
return JSON.stringify([{
58+
selectedIndex: nextState.selectedIndex,
59+
items: nextState.items,
60+
pickerStyle: nextState.pickerStyle,
61+
itemStyle: nextState.itemStyle,
62+
onValueChange: nextState.onValueChange
63+
}, context]) !== JSON.stringify([{
64+
selectedIndex: this.state.selectedIndex,
65+
items: this.state.items,
66+
pickerStyle: this.state.pickerStyle,
67+
itemStyle: this.state.itemStyle,
68+
onValueChange: this.state.onValueChange
69+
}, this.context]);
5870
}
5971

6072
_stateFromProps(props){

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-picker-android",
3-
"version": "0.3.6",
3+
"version": "0.3.7",
44
"description": "react-native-picker-android",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)