Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

refactor(admin): optimize default tab rendering in product creation form

Jakub Sieradzki701826c71723
diff --git a/packages/admin/src/pages/products/product-create/components/product-create-form/product-create-form.tsx b/packages/admin/src/pages/products/product-create/components/product-create-form/product-create-form.tsx
index beebe35fd..2f3d0fd69 100644
--- a/packages/admin/src/pages/products/product-create/components/product-create-form/product-create-form.tsx
+++ b/packages/admin/src/pages/products/product-create/components/product-create-form/product-create-form.tsx
@@ -173,15 +173,18 @@ export const ProductCreateForm = ({
[watchedVariants],
);
- const defaultTabs = (
- <>
- <ProductCreateDetailsForm key="details" />
- <ProductCreateOrganizeForm key="organize" />
- <ProductCreateVariantsForm key="variants" />
- <ProductCreateInventoryKitForm key="inventory" />
- </>
+ const defaultTabs = useMemo(
+ () => [
+ <ProductCreateDetailsForm key="details" />,
+ <ProductCreateOrganizeForm key="organize" />,
+ <ProductCreateVariantsForm key="variants" />,
+ <ProductCreateInventoryKitForm key="inventory" />,
+ ],
+ [],
);
+ const hasCustomChildren = Children.count(children) > 0;
+
return (
<TabbedForm
form={form}
@@ -239,7 +242,7 @@ export const ProductCreateForm = ({
</div>
)}
>
- {Children.count(children) > 0 ? children : defaultTabs}
+ {hasCustomChildren ? children : defaultTabs}
</TabbedForm>
);
};