Skip to content
This repository was archived by the owner on Aug 29, 2020. It is now read-only.

Commit 803401e

Browse files
committed
Only dispatch loading when currently not loading
1 parent 08576cf commit 803401e

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

lib/use-google-autocomplete.js

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

lib/use-google-autocomplete.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-google-autocomplete",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "A tiny React Hook that returns Google Autocomplete results, with session_token handling.",
55
"keywords": [
66
"google maps",

src/use-google-autocomplete.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ export default function useGoogleAutocomplete({
6161
// Cancel previous debounced call.
6262
if (debouncedFn.current) debouncedFn.current.clear()
6363

64-
dispatch({
65-
type: 'LOADING',
66-
})
64+
if (!state.isLoading) {
65+
dispatch({
66+
type: 'LOADING',
67+
})
68+
}
6769

6870
debouncedFn.current = debounce(() => {
6971
const types =
@@ -83,7 +85,6 @@ export default function useGoogleAutocomplete({
8385
fetch(url, { signal: abortSignal.current })
8486
.then(data => data.json())
8587
.then(data => {
86-
console.log('data', data)
8788
dispatch({
8889
type: data.status,
8990
payload: {

0 commit comments

Comments
 (0)