diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/misc.tsx | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index 653f6bf..e52a57f 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -74,10 +74,11 @@ export function useAwaiter<T>(factory: () => Promise<T>, fallbackValue: T | null * @param factory Function returning a Component * @returns Result of factory function */ -export function LazyComponent<T = any>(factory: () => React.ComponentType<T>) { +export function LazyComponent<T extends JSX.IntrinsicAttributes = any>(factory: () => React.ComponentType<T>) { + const get = makeLazy(factory); return (props: T) => { - const Component = React.useMemo(factory, []); - return <Component {...props as any /* I hate react typings ??? */} />; + const Component = get(); + return <Component {...props} />; }; } |