aboutsummaryrefslogtreecommitdiff
path: root/src/utils/misc.tsx
diff options
context:
space:
mode:
authorVendicated <vendicated@riseup.net>2022-11-06 18:37:01 +0100
committerVendicated <vendicated@riseup.net>2022-11-06 18:37:01 +0100
commit963a7332b4daa183ec2d8d3ddf10f3f73b01746a (patch)
tree6eaecd2af5bc67222eb9748c7bf948fbf3c17a1a /src/utils/misc.tsx
parent440baf6028be926929497c14e9ab4610cddd255d (diff)
downloadVencord-963a7332b4daa183ec2d8d3ddf10f3f73b01746a.tar.gz
Vencord-963a7332b4daa183ec2d8d3ddf10f3f73b01746a.tar.bz2
Vencord-963a7332b4daa183ec2d8d3ddf10f3f73b01746a.zip
Migrate proxied components to and fix LazyComponent
Diffstat (limited to 'src/utils/misc.tsx')
-rw-r--r--src/utils/misc.tsx7
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} />;
};
}