aboutsummaryrefslogtreecommitdiffstats
path: root/src/components
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2026-06-07 21:25:28 -0700
committerPinapelz <yukais@pinapelz.com>2026-06-07 21:25:28 -0700
commit01e417ed08a8327169e6488a557c46b6a7b97a08 (patch)
tree499cabb53a48e79f1f2f6379b6c4c8506b619798 /src/components
parent4e54dfe40b0c20c5b4d4c20b288a8eb8a3805280 (diff)
bundle song list statically, improve search timeHEADmaster
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Search/index.tsx27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx
index 7f9d502..4d1ae83 100644
--- a/src/components/Search/index.tsx
+++ b/src/components/Search/index.tsx
@@ -11,30 +11,18 @@ interface Props {
}
export function Search({ currentTry, setSelectedSong }: Props) {
- const [value, setValue] = React.useState<string>("");
+ const [value, setValue] = React.useState("");
const [results, setResults] = React.useState<Song[]>([]);
React.useEffect(() => {
- let cancelled = false;
-
- async function runSearch() {
- if (!value) {
- setResults([]);
- return;
- }
- const songs = await searchSong(value);
-
- if (!cancelled) {
- setResults(songs);
- }
+ if (!value.trim()) {
+ setResults([]);
+ return;
}
- runSearch();
- return () => {
- cancelled = true;
- };
+
+ setResults(searchSong(value));
}, [value]);
- // clear value on selection
React.useEffect(() => {
setValue("");
}, [currentTry]);
@@ -57,13 +45,14 @@ export function Search({ currentTry, setSelectedSong }: Props) {
</Styled.Result>
))}
</Styled.ResultsContainer>
+
<Styled.SearchContainer>
<Styled.SearchPadding>
<IoSearch size={20} />
<Styled.Input
+ value={value}
onChange={(e) => setValue(e.currentTarget.value)}
placeholder="Search"
- value={value}
/>
</Styled.SearchPadding>
</Styled.SearchContainer>
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage