fix circular import bricking browser version

This commit is contained in:
V 2023-11-23 06:43:22 +01:00
parent 0f74817e25
commit f39f16d34b
No known key found for this signature in database
GPG key ID: A1DC0CFB5615D905
3 changed files with 26 additions and 19 deletions

View file

@ -18,9 +18,10 @@
import { React, useEffect, useMemo, useReducer, useState } from "@webpack/common";
import { makeLazy } from "./lazy";
import { checkIntersecting } from "./misc";
export * from "./lazyReact";
export const NoopComponent = () => null;
/**
@ -143,17 +144,3 @@ export function useTimer({ interval = 1000, deps = [] }: TimerOpts) {
return time;
}
/**
* A lazy component. The factory method is called on first render.
* @param factory Function returning a Component
* @param attempts How many times to try to get the component before giving up
* @returns Result of factory function
*/
export function LazyComponent<T extends object = any>(factory: () => React.ComponentType<T>, attempts = 5) {
const get = makeLazy(factory, attempts);
return (props: T) => {
const Component = get() ?? NoopComponent;
return <Component {...props} />;
};
}