Skip to content

Instantly share code, notes, and snippets.

@MustSeeMelons
Created December 22, 2020 15:03
Show Gist options
  • Save MustSeeMelons/2fef47db055637f56c396ef962b50d75 to your computer and use it in GitHub Desktop.
Save MustSeeMelons/2fef47db055637f56c396ef962b50d75 to your computer and use it in GitHub Desktop.
Show The Logs Harold - Listen for element change
useEffect(() => {
if (activeFilterElement !== 0) {
setActiveFilterElement(0);
const hasElements =
refStore[REF_KEY.FILTER_ELEMENTS] &&
(refStore[REF_KEY.FILTER_ELEMENTS] as HTMLElement[]).length > 0;
hasElements &&
(refStore[REF_KEY.FILTER_ELEMENTS][0] as HTMLElement).scrollIntoView({
behavior: "smooth",
});
}
}, [props.filterElementsUpdate]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment