Skip to content

Commit

Permalink
Merge pull request #288 from pantheon-systems/users/kestub/HandleNoRe…
Browse files Browse the repository at this point in the history
…actComponent

PCC-1473 Gracefully handle implementation edge case where no react component was provided in component map
  • Loading branch information
kevinstubbs authored Jul 15, 2024
2 parents 3b90145 + e7d5252 commit 8208018
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-ladybugs-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pantheon-systems/pcc-react-sdk": patch
---

Gracefully handle implementation edge case where a smart component map was provided to the ArticlerRenderer but without defining the react components that should be used.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ const MarkdownRenderer = ({
const { reactComponent: Component } = smartComponentMap[type];
const decodedAttrs = isomorphicBase64Decode(attrs);

if (!Component) {
return (
<div>
Error: Cannot render {type} because it was provided without a
reactComponent property.
</div>
);
}

return (
<div>
{disableDefaultErrorBoundaries ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ const PantheonTreeRenderer = ({
const component = smartComponentMap?.[componentType];

if (component) {
if (!component.reactComponent) {
return (
<div>
Error: Cannot render {componentType} because it was provided without
a reactComponent property.
</div>
);
}

return disableDefaultErrorBoundaries
? React.createElement(
component.reactComponent,
Expand Down

0 comments on commit 8208018

Please sign in to comment.