Skip to content

Commit 18af1e2

Browse files
author
Muhammad Haris
committed
Added debounce to input
1 parent e6f0e88 commit 18af1e2

File tree

5 files changed

+48
-14
lines changed

5 files changed

+48
-14
lines changed

assets/js/components/searchForm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import qs from 'query-string';
3+
import { DebounceInput } from 'react-debounce-input';
34
import SearchResults from './searchResults';
45

56
export default class SearchForm extends React.Component {
@@ -98,7 +99,7 @@ export default class SearchForm extends React.Component {
9899
render() {
99100
return (
100101
<div className={ `${ this.getFormClass() }` }>
101-
<input className="search-input" type="text" onChange={ this.getResults } placeholder={ wds_react_post_search.placeholder_text } />
102+
<DebounceInput debounceTimeout={ 300 } className="search-input" type="text" onChange={ this.getResults } placeholder={ wds_react_post_search.placeholder_text } />
102103
<SearchResults searched={ this.state.searched } loading={ this.state.loading } results={ this.state.results } lengthError={ this.state.lengthError } empty={ this.state.empty } />
103104
</div>
104105
)

assets/js/public.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

class-wds-react-post-search.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: WDS React Post Search
44
* Description: Power up the basic WordPress search with React.
55
* Plugin URI: https://www.webdevstudios.com
6-
* Version: 1.0.3
6+
* Version: 1.0.4
77
*
88
* With help from:
99
* https://www.ibenic.com/wordpress-react-search/

package-lock.json

Lines changed: 36 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
{
22
"name": "wds-react-post-search",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "Power up the basic WordPress search field with React.",
55
"main": "assets/js/public.js",
66
"dependencies": {
77
"@wordpress/html-entities": "^2.0.2",
8+
"awesome-debounce-promise": "^1.0.0",
89
"babel-core": "^6.26.3",
910
"babel-loader": "^7.1.4",
1011
"babel-preset-env": "^1.7.0",
1112
"babel-preset-react": "^6.24.1",
1213
"install": "^0.12.2",
1314
"npm": "^6.4.1",
1415
"query-string": "^6.2.0",
15-
"react": "^16.5.2",
16+
"react": "^16.6.3",
17+
"react-debounce-input": "^3.2.0",
1618
"react-dom": "^16.5.2",
1719
"webpack": "^4.21.0"
1820
},

0 commit comments

Comments
 (0)