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) {
const get = makeLazy(factory, attempts);
let failed = false;
const LazyComponent = (props: T) => {
const Component = get() ?? (() => {
if (!failed) {
failed = true;
console.error(`LazyComponent factory failed:\n${factory}`);
}
let Component = (() => {
console.error(`LazyComponent factory failed:\n\n${factory}`);
return NoopComponent;
})();
})() as React.ComponentType<T>;
// @ts-ignore
if (!get.$$vencordLazyFailed()) {
const result = get();
if (result != null) {
Component = result;
}
}
return <Component {...props} />;
};