Skip to content

Commit

Permalink
Fix useCallback for useSectionsRefecence
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrucs committed Mar 19, 2024
1 parent 6fc6f0f commit 70c380d
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions frontend/src/hooks/useSectionsReferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,25 @@ const useSectionsReferences = () => {
);

const handleResize = useCallback(
debounce(
() => {
setSectionsPositions(currentSectionsPositions => {
if (sectionsReferences.current === null) {
return currentSectionsPositions;
}
return Object.entries(sectionsReferences.current).reduce(
(obj, [name, ref]) => ({
...obj,
[name]: getDimensions(ref),
}),
{},
);
});
},
1000,
false,
),
() =>
debounce(
() => {
setSectionsPositions(currentSectionsPositions => {
if (sectionsReferences.current === null) {
return currentSectionsPositions;
}
return Object.entries(sectionsReferences.current).reduce(
(obj, [name, ref]) => ({
...obj,
[name]: getDimensions(ref),
}),
{},
);
});
},
1000,
false,
),
[],
);

Expand Down

0 comments on commit 70c380d

Please sign in to comment.