Skip to content

Commit

Permalink
feat: gracefully fallback if component definition doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Aug 14, 2023
1 parent 9e57649 commit d7e3190
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion packages/core/components/Puck/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,11 @@ export function Puck({
editMode: true,
})
) : (
<div>No configuration for {item.type}</div>
<div
style={{ padding: 48, textAlign: "center" }}
>
No configuration for {item.type}
</div>
)}
</div>
</DraggableComponent>
Expand Down
8 changes: 6 additions & 2 deletions packages/core/components/Render/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@ import { Config, Data } from "../../types/Config";

export function Render({ config, data }: { config: Config; data: Data }) {
const children = data.content.map((item) => {
const Component = config.components[item.type].render;
const Component = config.components[item.type]?.render;

return <Component key={item.props.id} {...item.props} />;
if (Component) {
return <Component key={item.props.id} {...item.props} />;
}

return null;
});

if (config.root) {
Expand Down

0 comments on commit d7e3190

Please sign in to comment.