From 64e323608b02793db1bc35158b7df251246db118 Mon Sep 17 00:00:00 2001 From: Yevhen Kapelianovych Date: Thu, 25 Apr 2024 11:54:25 +0300 Subject: [PATCH] Return getters from the "For" and "Show" components directly instead of creating excessive element objects. --- packages/moru/components.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/moru/components.js b/packages/moru/components.js index 79a4d33..d8279c2 100644 --- a/packages/moru/components.js +++ b/packages/moru/components.js @@ -1,6 +1,5 @@ import { memo } from "./enhancers.js"; import { immediately } from "./context.js"; -import { createElement } from "./element.js"; export const For = ( { each, children, fallback, key = (item) => item }, @@ -76,7 +75,7 @@ export const For = ( immediately, ); - const List = memo( + return memo( context, () => { const items = elements(); @@ -85,15 +84,13 @@ export const For = ( }, [elements], ); - - return createElement(List, {}); }; export const Show = ({ when, fallback, children }, context) => { let renderedChildren; let renderedFallback; - const Conditional = memo( + return memo( context, () => when() @@ -101,6 +98,4 @@ export const Show = ({ when, fallback, children }, context) => { : (renderedFallback ??= context.resolve(fallback)), [when], ); - - return createElement(Conditional, {}); };