-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[update(state)][decks]: update deck loading state
DESCRIPTION: This commit updates the state management for decks to include a loading state. ISSUES: Still loading too slowly.
- Loading branch information
Showing
23 changed files
with
534 additions
and
263 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ package-lock.json | |
# production | ||
/build | ||
/future-additions | ||
/dev | ||
|
||
# misc | ||
.DS_Store | ||
|
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,29 @@ | ||
import { useState, useEffect } from 'react'; | ||
/** | ||
* useDebounce hook | ||
* | ||
* @param {any} value - The value to be debounced. | ||
* @param {number} delay - The number of milliseconds to delay. | ||
* @returns {any} - The debounced value after the specified delay. | ||
*/ | ||
function useDebounce(value, delay) { | ||
// State and setters for debounced value | ||
const [debouncedValue, setDebouncedValue] = useState(value); | ||
const [delayTime, setDelayTime] = useState(delay || 500); | ||
|
||
useEffect(() => { | ||
// Update debounced value after the specified delay | ||
const handler = setTimeout(() => { | ||
setDebouncedValue(value); | ||
}, delay); | ||
|
||
// Cleanup function to cancel the timeout if value or delay changes | ||
return () => { | ||
clearTimeout(handler); | ||
}; | ||
}, [value, delay]); // Only re-run effect if value or delay changes | ||
|
||
return debouncedValue; | ||
} | ||
|
||
export default useDebounce; |
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
Oops, something went wrong.