Skip to content

Commit

Permalink
feat: scroll to top on page render
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Jul 19, 2024
1 parent 5dc39a1 commit 60a9260
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/sections/collection/Collection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { PageNotFound } from '../page-not-found/PageNotFound'
import { CollectionSkeleton } from './CollectionSkeleton'
import { CollectionInfo } from './CollectionInfo'
import { Trans, useTranslation } from 'react-i18next'
import { useScrollTop } from '../../shared/hooks/useScrollTop'

interface CollectionProps {
repository: CollectionRepository
Expand All @@ -31,6 +32,7 @@ export function Collection({
page,
infiniteScrollEnabled = false
}: CollectionProps) {
useScrollTop()
const { user } = useSession()
const { collection, isLoading } = useCollection(repository, id)
const { t } = useTranslation('collection')
Expand Down
7 changes: 7 additions & 0 deletions src/shared/hooks/useScrollTop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { useEffect } from 'react'

export const useScrollTop = () => {
useEffect(() => {
window.scrollTo({ top: 0, behavior: 'smooth' })
}, [])
}

0 comments on commit 60a9260

Please sign in to comment.