Migrate proxied components to and fix LazyComponent

This commit is contained in:
Vendicated 2022-11-06 18:37:01 +01:00
parent 440baf6028
commit 963a7332b4
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
6 changed files with 24 additions and 21 deletions

View file

@ -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} />;
};
}