diff --git a/src/webpack/webpack.tsx b/src/webpack/webpack.tsx index 23b3e0992..f8945c28b 100644 --- a/src/webpack/webpack.tsx +++ b/src/webpack/webpack.tsx @@ -189,20 +189,16 @@ export function findComponent(filter: FilterFn, parse: ( if (IS_DEV && !isIndirect) webpackSearchHistory.push(["findComponent", [filter]]); - let noMatchLogged = false; - const NoopComponent = (() => { - if (!noMatchLogged) { - noMatchLogged = true; + let InnerComponent = null as null | React.ComponentType; + + let findFailedLogged = false; + const WrapperComponent = (props: T) => { + if (InnerComponent === null && !findFailedLogged) { + findFailedLogged = true; logger.error(`Webpack find matched no module. Filter: ${printFilter(filter)}`); } - return null; - }) as React.ComponentType; - - let InnerComponent = NoopComponent; - - const WrapperComponent = (props: T) => { - return ; + return InnerComponent && ; }; WrapperComponent.$$vencordGetter = () => InnerComponent; @@ -213,7 +209,7 @@ export function findComponent(filter: FilterFn, parse: ( Object.assign(InnerComponent, parsedComponent); }, { isIndirect: true }); - if (InnerComponent !== NoopComponent) return InnerComponent; + if (InnerComponent !== null) return InnerComponent; return WrapperComponent; } @@ -236,20 +232,16 @@ export function findExportedComponent(...props: string[] if (IS_DEV) webpackSearchHistory.push(["findExportedComponent", props]); - let noMatchLogged = false; - const NoopComponent = (() => { - if (!noMatchLogged) { - noMatchLogged = true; + let InnerComponent = null as null | React.ComponentType; + + let findFailedLogged = false; + const WrapperComponent = (props: T) => { + if (InnerComponent === null && !findFailedLogged) { + findFailedLogged = true; logger.error(`Webpack find matched no module. Filter: ${printFilter(filter)}`); } - return null; - }) as React.ComponentType; - - let InnerComponent = NoopComponent; - - const WrapperComponent = (props: T) => { - return ; + return InnerComponent && ; }; WrapperComponent.$$vencordGetter = () => InnerComponent; @@ -260,7 +252,7 @@ export function findExportedComponent(...props: string[] Object.assign(InnerComponent, parsedComponent); }, { isIndirect: true }); - if (InnerComponent !== NoopComponent) return InnerComponent; + if (InnerComponent !== null) return InnerComponent; return WrapperComponent as React.ComponentType; }