Skip to content

Commit

Permalink
fix(root): fix website crashing when selecting react on component pre…
Browse files Browse the repository at this point in the history
…view

fix website crashing when selecting react on a component preview that only has the react option

fix #1173
  • Loading branch information
lz405 committed Oct 28, 2024
1 parent 1509ce5 commit e332682
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/CodePreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -511,12 +511,16 @@ const ComponentPreview: React.FC<ComponentPreviewProps> = ({
type={type}
code={
getCodeSnippet(
selectedTab === "Web component" ? snippets[0] : snippets[1]
selectedTab === "Web component"
? snippets[0]
: snippets[1] ?? snippets[0]
)?.codeSnippet || ""
}
longCode={
getCodeSnippet(
selectedTab === "Web component" ? snippets[0] : snippets[1]
selectedTab === "Web component"
? snippets[0]
: snippets[1] ?? snippets[0]
)?.longCode || ""
}
show={show}
Expand All @@ -527,16 +531,18 @@ const ComponentPreview: React.FC<ComponentPreviewProps> = ({
isWebComponents={
(selectedTab === "Web component"
? snippets[0].technology
: snippets[1].technology) === "Web component"
: (snippets[1] ?? snippets[0]).technology) === "Web component"
}
projectTitle={`${
projectTitle || startCase(pageMetadata.pageTitle)
} (${
selectedTab === "Web component"
? snippets[0].technology
: snippets[1].technology
: (snippets[1] ?? snippets[0]).technology
}${getTypeOfProject(
selectedTab === "Web component" ? snippets[0] : snippets[1]
selectedTab === "Web component"
? snippets[0]
: snippets[1] ?? snippets[0]
)})`}
projectDescription={
projectDescription === undefined || projectDescription === ""
Expand Down

0 comments on commit e332682

Please sign in to comment.