Skip to content

Instantly share code, notes, and snippets.

@gavrya
Forked from jrwebdev/loading-hoc-sfc.tsx
Created March 24, 2020 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavrya/368cab4fefc320da1146bbe610978e51 to your computer and use it in GitHub Desktop.
Save gavrya/368cab4fefc320da1146bbe610978e51 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