react-native-searchable-dropdown
Advanced tools
Comparing version 1.0.3 to 1.0.4
26
index.js
@@ -31,3 +31,3 @@ import React, { Component } from 'react'; | ||
dataSource={ds.cloneWithRows(this.state.listItems)} | ||
renderRow={this.renderAdress} /> | ||
renderRow={this.renderItems} /> | ||
) | ||
@@ -37,14 +37,14 @@ } | ||
static getDerivedStateFromProps (props, store) { | ||
let listItems = props.items ? props.items : [ { id: 0, 'name': '' } ]; | ||
if(props.resetValue === true){ | ||
return { listItems: listItems, item: { id: 0, name: '' } } | ||
}else{ | ||
return { listItems: listItems } | ||
} | ||
} | ||
componentDidMount(){ | ||
let listItems = this.props.items; | ||
this.setState({listItems}); | ||
const listItems = this.props.items; | ||
const defaultIndex = this.props.defaultIndex; | ||
if (defaultIndex && listItems.length > defaultIndex) { | ||
this.setState({ | ||
listItems, | ||
item: listItems[defaultIndex] | ||
}); | ||
} | ||
else { | ||
this.setState({listItems}); | ||
} | ||
} | ||
@@ -70,3 +70,3 @@ | ||
renderAdress = (item) => { | ||
renderItems = (item) => { | ||
return ( | ||
@@ -73,0 +73,0 @@ <TouchableOpacity style={{ ...this.props.itemStyle }} onPress={() => { |
{ | ||
"name": "react-native-searchable-dropdown", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Searchable Dropdown", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -30,4 +30,8 @@ [example-url]: https://i.imgur.com/mHGaOX5.gif | ||
<tr> | ||
<td>defaultIndex</td> | ||
<td>Default selected index of items. (optional)</td> | ||
</tr> | ||
<tr> | ||
<td>onTextChange</td> | ||
<td>on text change you can passs onTextChange and catch the input text. </td> | ||
<td>on text change you can passs onTextChange and catch the input text. (optional)</td> | ||
</tr> | ||
@@ -140,2 +144,3 @@ <tr> | ||
items={items} | ||
defaultIndex={2} | ||
placeholder="Placeholder." | ||
@@ -142,0 +147,0 @@ resetValue={false} |
6514
104
150