-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
152 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
export default function useDebounce(value: string, delay: number) { | ||
// State and setters for debounced value | ||
const [debouncedValue, setDebouncedValue] = useState(value); | ||
|
||
useEffect( | ||
() => { | ||
// Update debounced value after delay | ||
const handler = setTimeout(() => { | ||
setDebouncedValue(value); | ||
}, delay); | ||
|
||
// Cancel the timeout if value changes (also on delay change or unmount) | ||
// This is how we prevent debounced value from updating if value is changed ... | ||
// .. within the delay period. Timeout gets cleared and restarted. | ||
return () => { | ||
clearTimeout(handler); | ||
}; | ||
}, | ||
[value, delay] // Only re-call effect if value or delay changes | ||
); | ||
|
||
return debouncedValue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useQuery } from "react-query"; | ||
import { TransactionService } from "../services/TransactionService"; | ||
import { VideoService } from "../services/VideoService"; | ||
|
||
export function useSearchVideoByKeyword(key: string) { | ||
const query = useQuery(["video", key], () => { | ||
return VideoService.searchVideo(key); | ||
}); | ||
|
||
return query; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fff29d0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
video-trading – ./
video-trading-git-main-etherdata-blockchain.vercel.app
video-trading-etherdata-blockchain.vercel.app
www.video2.trade
video-trading.vercel.app
vxvhk.com
video2.trade
www.vxvhk.com