Skip to content

Commit

Permalink
Show indicator while searching (#16)
Browse files Browse the repository at this point in the history
* Show indicator while searching

* Use onSearch instead of onPressEnter

Changed to onSearch because the search button does not work.
  • Loading branch information
leey0818 authored May 31, 2020
1 parent 4cb7c0c commit 19d6d32
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { loadSettings, updateSettings, getRuntime } from "./utils";

export const App = () => {
const [searchValue, setSearchValue] = React.useState("");
const [showLoading, setShowLoading] = React.useState(false);
const [showEngAddr, setShowEngAddr] = React.useState(true);
const [showRoadAddr, setShowRoadAddr] = React.useState(true);
const [showLegacyAddr, setShowLegacyAddr] = React.useState(true);
Expand All @@ -26,6 +27,8 @@ export const App = () => {
}, [setSearchValue]);

const handleSearchClick = React.useCallback(() => {
setShowLoading(true);

addrManager.current.search({
countPerPage: "20",
currentPage: "1",
Expand All @@ -34,8 +37,10 @@ export const App = () => {
setAddressData(data);
}).catch((err) => {
console.error(err);
}).finally(() => {
setShowLoading(false);
});
}, [searchValue, setAddressData]);
}, [searchValue, setAddressData, setShowLoading]);

const handleSearchOptionClick = React.useCallback((type: "eng" | "road" | "legacy") => async () => {
if (updatingSettings) {
Expand Down Expand Up @@ -125,8 +130,9 @@ export const App = () => {
<Input.Search
enterButton allowClear
value={searchValue}
loading={showLoading}
onChange={handleSearchValueChange}
onPressEnter={handleSearchClick} />
onSearch={handleSearchClick} />
</Layout.Content>
<Layout.Content>
<AddressList
Expand Down

0 comments on commit 19d6d32

Please sign in to comment.