Skip to content

Commit

Permalink
Fixed scroll overlay in medicine dashboard (#7517)
Browse files Browse the repository at this point in the history
* Check scroll effect

* re-use `useEffect` hooks and correct dependencies

---------

Co-authored-by: rithviknishad <[email protected]>
  • Loading branch information
AshrafMd-1 and rithviknishad authored Apr 9, 2024
1 parent 7b52db0 commit 34648e9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Utils/useVisibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export default function useVisibility<Element extends HTMLElement>(
};

useEffect(() => {
onScroll();
document.addEventListener("scroll", onScroll, true);
return () => document.removeEventListener("scroll", onScroll, true);
});
}, [currentElement.current]);

return [isVisible, currentElement];
}

0 comments on commit 34648e9

Please sign in to comment.