diff --git a/src/utils/createCustomNameComponent.tsx b/src/utils/createCustomNameComponent.tsx index daf5866..802ea13 100644 --- a/src/utils/createCustomNameComponent.tsx +++ b/src/utils/createCustomNameComponent.tsx @@ -12,6 +12,7 @@ interface Options { export function createCustomNameComponent(loader: () => Promise, options: Options = {}): () => Promise { const { name } = options; let component: Component | null = null; + let wrappedComponent: Component | null = null; const load = async () => { try { @@ -27,13 +28,15 @@ export function createCustomNameComponent(loader: () => Promise, options: O await load(); } - return Promise.resolve( - defineComponent({ + if (!wrappedComponent) { + wrappedComponent = defineComponent({ name, render() { return h(component as Component); } - }) - ); + }); + } + + return Promise.resolve(wrappedComponent); }; }