diff options
author | Vendicated <vendicated@riseup.net> | 2022-11-06 18:37:01 +0100 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-11-06 18:37:01 +0100 |
commit | 963a7332b4daa183ec2d8d3ddf10f3f73b01746a (patch) | |
tree | 6eaecd2af5bc67222eb9748c7bf948fbf3c17a1a /src/utils | |
parent | 440baf6028be926929497c14e9ab4610cddd255d (diff) | |
download | Vencord-963a7332b4daa183ec2d8d3ddf10f3f73b01746a.tar.gz Vencord-963a7332b4daa183ec2d8d3ddf10f3f73b01746a.tar.bz2 Vencord-963a7332b4daa183ec2d8d3ddf10f3f73b01746a.zip |
Migrate proxied components to and fix LazyComponent
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} />; }; } |