I have this code for set scroll event to window and my container, but I think it is not good to use document in react component
const closeMenu = () => {
setIsActionListVisible(false);
};
useEffect(() => {
window.addEventListener("scroll", closeMenu);
const layout = document.getElementsByClassName("common-home-layout");
if (layout) {
layout[0].addEventListener("scroll", closeMenu);
}
}, []);
Maybe do you have any better case for that?
getElementsByClassNameinstead ofquerySelector?