Skip to content

Instantly share code, notes, and snippets.

@rockonyu
Forked from jrwebdev/loading-hoc-sfc.tsx
Created July 17, 2020 08:34
Show Gist options
  • Save rockonyu/43d1ad68c8acb64f604cd34814cff7bc to your computer and use it in GitHub Desktop.
Save rockonyu/43d1ad68c8acb64f604cd34814cff7bc to your computer and use it in GitHub Desktop.
const withLoading = <P extends object>(
Component: React.ComponentType<P>
): React.FC<P & WithLoadingProps> => ({
loading,
...props
}: WithLoadingProps) =>
loading ? <LoadingSpinner /> : <Component {...props as P} />;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment