Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/react/src/components/Placeholder/placeholder-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,22 @@ export const getComponentForRendering = (
// Render SXA Rendering Variant if available
const exportName = renderingDefinition.params?.FieldNames;

const renderedComponent =
// Try to find a named export matching the variant, otherwise fallback to default export
const variantComponent =
exportName && exportName !== DEFAULT_EXPORT_NAME
? ((component as ReactModule)[exportName] as ComponentType)
: (component as ReactModule).default ||
(component as ReactModule).Default ||
(component as ComponentType);
: undefined;

const defaultComponent =
(component as ReactModule).default ||
(component as ReactModule).Default ||
(component as ComponentType);

// Use variant if found, otherwise fallback to default export
const renderedComponent = variantComponent || defaultComponent;

if (!renderedComponent) {
logUnknownComponentError(exportName !== DEFAULT_EXPORT_NAME ? exportName : undefined);
logUnknownComponentError();

return {
component: missingComponentComponent ?? MissingComponent,
Expand Down