Skip to content

Commit

Permalink
feat: lazy.util
Browse files Browse the repository at this point in the history
- fix types for lazy
  • Loading branch information
denchiklut committed Dec 23, 2022
1 parent 9bdbc27 commit a908401
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/client/utils/lazy.util.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import lazy, { type DefaultComponent } from '@loadable/component'
import { Loader } from '@shared/loader'

type LoadFn = <Props>(props: Props) => Promise<DefaultComponent<Props>>
export const loadable = (fn: LoadFn) => lazy(fn, { fallback: <Loader /> })
interface LoadFn<T> {
(props: T): Promise<DefaultComponent<T>>
}

export const loadable = <T extends unknown>(fn: LoadFn<T>) => lazy(fn, { fallback: <Loader /> })

0 comments on commit a908401

Please sign in to comment.