-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a search bar to zerochan modal
improved the zerochan modal ux
- Loading branch information
Showing
7 changed files
with
133 additions
and
51 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
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
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
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,21 @@ | ||
import { type StateUpdater, useEffect, useState } from 'preact/hooks'; | ||
|
||
export const useDebounce = <T,>( | ||
initialValue: T, | ||
time: number, | ||
): [T, T, StateUpdater<T>] => { | ||
const [value, setValue] = useState<T>(initialValue); | ||
const [debouncedValue, setDebouncedValue] = useState<T>(initialValue); | ||
|
||
useEffect(() => { | ||
const debounce = setTimeout(() => { | ||
setDebouncedValue(value); | ||
}, time); | ||
|
||
return () => { | ||
clearTimeout(debounce); | ||
}; | ||
}, [value, time]); | ||
|
||
return [debouncedValue, value, setValue]; | ||
}; |