Skip to content

Instantly share code, notes, and snippets.

@gillkyle
Created July 31, 2021 22:33
Show Gist options
  • Save gillkyle/1db255290d06733d7f01a7e319838faf to your computer and use it in GitHub Desktop.
Save gillkyle/1db255290d06733d7f01a7e319838faf to your computer and use it in GitHub Desktop.
Pass a status prop, if loading, render the skeleton, when loaded, the children.
import * as React from 'react'
import { Skeleton } from '@chakra-ui/react'
export default function SkeletonLoader({ skeletonProps, status, children }) {
if (status === 'loading')
return <Skeleton height="100%" width="100%" {...skeletonProps} />
if (status === 'error') return null
return children
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment