From d2e86c8d1c92374384fd57e49fd8315dc01ec206 Mon Sep 17 00:00:00 2001 From: gabrielkerekes Date: Tue, 31 Oct 2023 12:03:08 +0100 Subject: [PATCH] Scroll to products if `#products` in course detail url --- src/pages/kurzy/[slug]/index.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/kurzy/[slug]/index.tsx b/src/pages/kurzy/[slug]/index.tsx index 40f1777..9004475 100644 --- a/src/pages/kurzy/[slug]/index.tsx +++ b/src/pages/kurzy/[slug]/index.tsx @@ -115,12 +115,14 @@ const CourseDetailContent = ({ } } + setHasProductsInLocation(window.location.hash === '#products') + window.addEventListener('hashchange', handleHashChange) return () => { window.removeEventListener('hashchange', handleHashChange) } - }, []) + }, [setHasProductsInLocation]) useEffect(() => { if (hasProductsInLocation && courseProductsRef.current) {