Forgot to change this
This commit is contained in:
parent
3b1cb02663
commit
043675f3f8
|
@ -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} />;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue