Created
July 31, 2021 22:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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