mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
fix(live-codeblock): stabilize react-live transformCode callback, fix editor/preview desync (#9631)
This commit is contained in:
parent
61116e2ad6
commit
991429ff8a
|
|
@ -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,
|
||||
|
|
@ -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' ? (
|
||||
|
|
|
|||
Loading…
Reference in New Issue