Forgot to change this

This commit is contained in:
Nuckyz 2024-05-04 23:56:02 -03:00
parent 3b1cb02663
commit 043675f3f8
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9

View file

@ -19,16 +19,20 @@ export const NoopComponent = () => null;
export function LazyComponent<T extends object = any>(factory: () => React.ComponentType<T>, attempts = 5) { export function LazyComponent<T extends object = any>(factory: () => React.ComponentType<T>, attempts = 5) {
const get = makeLazy(factory, attempts); const get = makeLazy(factory, attempts);
let failed = false;
const LazyComponent = (props: T) => { const LazyComponent = (props: T) => {
const Component = get() ?? (() => { let Component = (() => {
if (!failed) { console.error(`LazyComponent factory failed:\n\n${factory}`);
failed = true;
console.error(`LazyComponent factory failed:\n${factory}`);
}
return NoopComponent; return NoopComponent;
})(); })() as React.ComponentType<T>;
// @ts-ignore
if (!get.$$vencordLazyFailed()) {
const result = get();
if (result != null) {
Component = result;
}
}
return <Component {...props} />; return <Component {...props} />;
}; };