-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(with loading hoc): make a separate component
- Loading branch information
1 parent
39b16ea
commit 75d8048
Showing
3 changed files
with
61 additions
and
56 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,5 +30,5 @@ yarn-error.log* | |
# IDE files | ||
.idea | ||
|
||
# generated filed | ||
# generated files | ||
/public/themes |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React, { Suspense } from 'react'; | ||
import { Loading } from '@app/components/common/Loading'; | ||
|
||
type ReturnType<T> = (props: T) => JSX.Element; | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export const withLoading = <T extends object>(Component: React.ComponentType<T>): ReturnType<T> => { | ||
return (props: T) => ( | ||
<Suspense fallback={<Loading />}> | ||
<Component {...props} /> | ||
</Suspense> | ||
); | ||
}; |