Skip to content

Commit

Permalink
Fix content flickering during main page load
Browse files Browse the repository at this point in the history
  • Loading branch information
8kto committed Feb 7, 2024
1 parent e3d8f89 commit cc4e230
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/InventoryPageTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const InventoryPageTabs = ({

if (!isMounted) {
return (
<>
<div className='min-h-screen'>
<Spinner />
</>
</div>
)
}

Expand Down
5 changes: 4 additions & 1 deletion src/components/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import React from 'react'

const Spinner = () => {
return (
<div role='status' className='flex h-1/3 items-center justify-center'>
<div
role='status'
className='flex min-h-screen items-center justify-center'
>
<svg
aria-hidden='true'
className='h-20 w-20 animate-spin fill-red-400 text-gray-200'
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Header = () => {
<nav className='ph-header-wrapper fixed z-30 w-full border-2 border-b border-gray-400 px-4 py-4 text-white'>
<div className='mx-auto flex w-full max-w-screen-2xl items-center justify-between px-0 sm:px-4 lg:px-4 xl:px-8'>
<div className='flex items-center'>
<Link href='/' className='flex items-center'>
<Link href='/inventory' className='flex items-center'>
<h1
className={`${cursiveFont.className} whitespace-nowrap text-3xl font-semibold`}
>
Expand Down
6 changes: 4 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import React, { useEffect } from 'react'

import Spinner from '@/components/Spinner'

const IndexPage = () => {
const router = useRouter()
Expand All @@ -8,7 +10,7 @@ const IndexPage = () => {
router.push('/inventory')
}, [router])

return null // Render nothing or a loader while redirecting
return <Spinner />
}

export default IndexPage

0 comments on commit cc4e230

Please sign in to comment.