Add webpack find testing (#2016)

Co-authored-by: V <vendicated@riseup.net>
Co-authored-by: Nuckyz <61953774+Nuckyz@users.noreply.github.com>
This commit is contained in:
V 2023-11-25 01:32:21 +01:00 committed by GitHub
parent 3e8e106be7
commit 534565db25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 289 additions and 97 deletions

View file

@ -76,7 +76,7 @@ handler.getOwnPropertyDescriptor = (target, p) => {
};
/**
* Wraps the result of {@see makeLazy} in a Proxy you can consume as if it wasn't lazy.
* Wraps the result of {@link makeLazy} in a Proxy you can consume as if it wasn't lazy.
* On first property access, the lazy is evaluated
* @param factory lazy factory
* @param attempts how many times to try to evaluate the lazy before giving up

View file

@ -16,8 +16,12 @@ const NoopComponent = () => null;
*/
export function LazyComponent<T extends object = any>(factory: () => React.ComponentType<T>, attempts = 5) {
const get = makeLazy(factory, attempts);
return (props: T) => {
const LazyComponent = (props: T) => {
const Component = get() ?? NoopComponent;
return <Component {...props} />;
};
LazyComponent.$$get = get;
return LazyComponent;
}