mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
memoize and reset scrollEnd handler on grid list
This commit is contained in:
@@ -265,7 +265,16 @@ export const ItemGridList = ({
|
|||||||
[onScrollEnd],
|
[onScrollEnd],
|
||||||
);
|
);
|
||||||
|
|
||||||
const debouncedOnScrollEnd = debounce(handleOnScrollEnd, 150);
|
const debouncedOnScrollEnd = useMemo(
|
||||||
|
() => debounce(handleOnScrollEnd, 150),
|
||||||
|
[handleOnScrollEnd],
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
debouncedOnScrollEnd.cancel();
|
||||||
|
};
|
||||||
|
}, [debouncedOnScrollEnd]);
|
||||||
|
|
||||||
const handleScroll = useCallback(
|
const handleScroll = useCallback(
|
||||||
(e: UIEvent<HTMLDivElement>) => {
|
(e: UIEvent<HTMLDivElement>) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user