Skip to content

Commit 95550eb

Browse files
authored
Wait for component to mount before calling setStringRawBody (#304)
1 parent 5f41e8d commit 95550eb

File tree

1 file changed

+6
-2
lines changed
  • packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/LiveEditor

1 file changed

+6
-2
lines changed

packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/LiveEditor/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* LICENSE file in the root directory of this source tree.
66
* ========================================================================== */
77

8-
import React, { useState } from "react";
8+
import React, { useEffect, useState } from "react";
99

1010
import { usePrismTheme } from "@docusaurus/theme-common";
1111
import useIsBrowser from "@docusaurus/useIsBrowser";
@@ -51,7 +51,11 @@ function App({
5151
}: any): JSX.Element {
5252
const prismTheme = usePrismTheme();
5353
const [code, setCode] = React.useState(children);
54-
action(setStringRawBody(code));
54+
55+
useEffect(() => {
56+
action(setStringRawBody(code));
57+
}, [action, code]);
58+
5559
return (
5660
<div className={styles.playgroundContainer}>
5761
<LiveProvider

0 commit comments

Comments
 (0)