react-native-modal-selector
Advanced tools
Comparing version 0.0.21 to 0.0.22
23
index.js
@@ -22,2 +22,3 @@ 'use strict'; | ||
let componentIndex = 0; | ||
let rnVersion = Number.parseFloat(require('react-native/package.json').version); | ||
@@ -87,2 +88,3 @@ const propTypes = { | ||
selected: 'please select', | ||
changedItem: undefined, | ||
}; | ||
@@ -103,5 +105,5 @@ } | ||
onChange(item) { | ||
this.props.onChange(item); | ||
this.setState({selected: item.label}); | ||
this.close(); | ||
rnVersion < 0.50 && this.props.onChange(item); | ||
this.setState({selected: item.label, changedItem: item }); | ||
this.close() | ||
} | ||
@@ -118,2 +120,3 @@ | ||
modalVisible: true, | ||
changedItem: undefined, | ||
}); | ||
@@ -130,6 +133,7 @@ } | ||
renderOption(option) { | ||
renderOption(option, isLastItem) { | ||
return ( | ||
<TouchableOpacity key={option.key} onPress={() => this.onChange(option)}> | ||
<View style={[styles.optionStyle, this.props.optionStyle]}> | ||
<View style={[styles.optionStyle, this.props.optionStyle, isLastItem && | ||
{borderBottomWidth: 0}]}> | ||
<Text style={[styles.optionTextStyle,this.props.optionTextStyle]}>{option.label}</Text> | ||
@@ -141,10 +145,10 @@ </View> | ||
renderOptionList() { | ||
let options = this.props.data.map(item => { | ||
let options = this.props.data.map((item, index) => { | ||
if (item.section) { | ||
return this.renderSection(item); | ||
} | ||
return this.renderOption(item); | ||
return this.renderOption(item, index === this.props.data.length - 1); | ||
}); | ||
const closeOverlay = this.props.backdropPressToClose; | ||
@@ -195,2 +199,3 @@ | ||
animationType={this.props.animationType} | ||
onDismiss={() => this.state.changedItem && this.props.onChange(this.state.changedItem)} | ||
> | ||
@@ -197,0 +202,0 @@ {this.renderOptionList()} |
{ | ||
"name": "react-native-modal-selector", | ||
"version": "0.0.21", | ||
"version": "0.0.22", | ||
"description": "A cross-platform (iOS / Android), selector/picker component for React Native that is highly customizable and supports sections.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20281
10
257
1