Skip to content

Commit

Permalink
stabilize react-live transformCode callback
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Dec 14, 2023
1 parent 61116e2 commit 8fbe4a2
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ function EditorWithHeader() {
);
}

// this should rather be a stable function
// see https://github.com/facebook/docusaurus/issues/9630#issuecomment-1855682643
const DEFAULT_TRANSFORM_CODE = (code: string) => `${code};`;

export default function Playground({
children,
transformCode,
Expand All @@ -118,7 +122,7 @@ export default function Playground({
<LiveProvider
code={children.replace(/\n$/, '')}
noInline={noInline}
transformCode={transformCode ?? ((code) => `${code};`)}
transformCode={transformCode ?? DEFAULT_TRANSFORM_CODE}
theme={prismTheme}
{...props}>
{playgroundPosition === 'top' ? (
Expand Down

0 comments on commit 8fbe4a2

Please sign in to comment.