Skip to content

Commit

Permalink
fix(live-codeblock): stabilize react-live transformCode callback, fix…
Browse files Browse the repository at this point in the history
… editor/preview desync (#9631)
  • Loading branch information
slorber committed Jan 5, 2024
1 parent 3c051ee commit 85e32fd
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 85e32fd

Please sign in to comment.