mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-20 20:07:03 -04:00
Migrate proxied components to and fix LazyComponent
This commit is contained in:
parent
440baf6028
commit
963a7332b4
6 changed files with 24 additions and 21 deletions
|
@ -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} />;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue