From a9a5a73d8d1fed02a2c16371a064998e0b387e10 Mon Sep 17 00:00:00 2001 From: Carlos Kelly Date: Thu, 8 Jun 2023 06:36:22 -0500 Subject: [PATCH] Fixed undefined themes causing a runtime error. --- .changeset/old-chicken-turn.md | 5 +++++ packages/prism-react-renderer/src/index.ts | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 .changeset/old-chicken-turn.md diff --git a/.changeset/old-chicken-turn.md b/.changeset/old-chicken-turn.md new file mode 100644 index 0000000..624ec6f --- /dev/null +++ b/.changeset/old-chicken-turn.md @@ -0,0 +1,5 @@ +--- +"prism-react-renderer": patch +--- + +Fixed bug where an undefined theme would cause a runtime error. diff --git a/packages/prism-react-renderer/src/index.ts b/packages/prism-react-renderer/src/index.ts index 16f4486..b1ef889 100644 --- a/packages/prism-react-renderer/src/index.ts +++ b/packages/prism-react-renderer/src/index.ts @@ -10,8 +10,10 @@ import { HighlightProps, PrismLib } from "./types" */ const Highlight = (props: HighlightProps) => createElement(InternalHighlight, { - prism: Prism as PrismLib, - theme: themes.vsDark, ...props, + prism: props.prism || (Prism as PrismLib), + theme: props.theme || themes.vsDark, + code: props.code, + language: props.language, }) export { Highlight, Prism, themes }