We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scroll events may be fired at a high frequency, without taking unwanted framerate drops into account.
A similar problem is present for virtual scrolling/windowing approaches. We should follow the thread below for further information:
The text was updated successfully, but these errors were encountered:
Issue #113 could provide a partial solution:
function useDebouncedWindowScrollCoords() { const coords = useWindowScrollCoords(); const [debouncedCoords, setDebouncedCoords] = useState(coords); const isChanging = useChanging(coords, 150); useEffect(() => { if (!isChanging) setDebouncedCoords(coords); }, [isChanging]); return debouncedCoords; }
The main drawback is that useWindowScrollCoords still features useState under the hood, which would cause unnecessary rerenders.
useWindowScrollCoords
useState
Sorry, something went wrong.
The code above could be made generic:
function useDebounce<T>(value: T, groupingIntervalMs?: number) { const [debouncedValue, setDebouncedValue] = useState(value); const isChanging = useChanging(value, groupingIntervalMs); useEffect(() => { if (!isChanging) setDebouncedValue(value); }, [isChanging]); return debouncedValue; }
After all, rerenders are not so problematic, especially with some room for additional optimization.
No branches or pull requests
Motivation
Scroll events may be fired at a high frequency, without taking unwanted framerate drops into account.
Details
A similar problem is present for virtual scrolling/windowing approaches. We should follow the thread below for further information:
The text was updated successfully, but these errors were encountered: