Skip to content

Commit 0e74f2f

Browse files
add custom wait interval
1 parent 3d0070c commit 0e74f2f

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export default withKeyboardAwareScrollView(HomeScreen);
113113
highlightText | Highlight search results | Boolean | true
114114
rightContent | Render additional text to the right of the item | Boolean | false
115115
minimumCharactersCount | Perform API request after certain number of characters entered | Number | 2
116+
waitInterval | Timeout between user finished typing and new data fetch | Number | 400
116117
placeholder | Autocomplete input placeholder text | String | Add Item
117118
placeholderColor | Input placeholder color | String | #acada9
118119
spinnerSize | Size of activity indicator | String | small

components/Autocomplete/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Autocomplete extends Component {
2929
}
3030

3131
handleInputChange(text) {
32-
const {minimumCharactersCount} = this.props;
32+
const {minimumCharactersCount, waitInterval} = this.props;
3333
clearTimeout(this.timer);
3434
this.setState({inputValue: text});
3535
if (text.length > minimumCharactersCount) {
@@ -39,7 +39,7 @@ class Autocomplete extends Component {
3939
},
4040
() => {
4141
if (this.mounted) {
42-
this.timer = setTimeout(this.triggerChange, WAIT_INTERVAL);
42+
this.timer = setTimeout(this.triggerChange, waitInterval);
4343
}
4444
},
4545
);
@@ -193,6 +193,7 @@ Autocomplete.defaultProps = {
193193
autoCorrect: false,
194194
minimumCharactersCount: 2,
195195
highlightText: true,
196+
waitInterval: WAIT_INTERVAL,
196197
};
197198

198199
Autocomplete.propTypes = {
@@ -202,6 +203,7 @@ Autocomplete.propTypes = {
202203
placeholderColor: string,
203204
fetchDataUrl: string,
204205
minimumCharactersCount: number,
206+
waitInterval: number,
205207
highlightText: bool,
206208
rightContent: bool,
207209
autoCorrect: bool,

0 commit comments

Comments
 (0)