Skip to content

Commit

Permalink
Wait for component to mount before calling setStringRawBody (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
sserrata authored Oct 18, 2022
1 parent 5f41e8d commit 95550eb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import React, { useState } from "react";
import React, { useEffect, useState } from "react";

import { usePrismTheme } from "@docusaurus/theme-common";
import useIsBrowser from "@docusaurus/useIsBrowser";
Expand Down Expand Up @@ -51,7 +51,11 @@ function App({
}: any): JSX.Element {
const prismTheme = usePrismTheme();
const [code, setCode] = React.useState(children);
action(setStringRawBody(code));

useEffect(() => {
action(setStringRawBody(code));
}, [action, code]);

return (
<div className={styles.playgroundContainer}>
<LiveProvider
Expand Down

0 comments on commit 95550eb

Please sign in to comment.