Skip to content

Commit 9b52be6

Browse files
authored
fix(PrismCode): accept nullish values (#693)
1 parent a764fee commit 9b52be6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

.changeset/fair-cycles-design.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Allow PrismCode to accept nullish values if they are passed.

src/components/content/PrismCode/PrismCode.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ function isDiffCode(code: string): boolean {
8080
}
8181

8282
function PrismCode(props: CubePrismCodeProps, ref) {
83-
const { code = '', language = 'javascript', ...otherProps } = props;
83+
let { code = '', language = 'javascript', ...otherProps } = props;
84+
85+
if (!code) {
86+
code = '';
87+
}
8488

8589
if (typeof code !== 'string' && code) {
8690
throw new Error(

0 commit comments

Comments
 (0)