-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import {useEffect} from "react"; | ||
import useIsBrowser from "@docusaurus/useIsBrowser"; | ||
|
||
const preventResizeObserverError = () => { | ||
const isBrowser = useIsBrowser(); | ||
useEffect(() => { | ||
if (isBrowser) { | ||
window.addEventListener('error', e => { | ||
if (e.message.includes('ResizeObserver loop')) { | ||
const resizeObserverErrDiv = document.getElementById( | ||
'webpack-dev-server-client-overlay-div' | ||
); | ||
const resizeObserverErr = document.getElementById( | ||
'webpack-dev-server-client-overlay' | ||
); | ||
if (resizeObserverErr) { | ||
resizeObserverErr.setAttribute('style', 'display: none'); | ||
} | ||
if (resizeObserverErrDiv) { | ||
resizeObserverErrDiv.setAttribute('style', 'display: none'); | ||
} | ||
} | ||
}); | ||
} | ||
}, [isBrowser]); | ||
} | ||
export default preventResizeObserverError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,32 @@ | ||
import {lazy} from "react"; | ||
import Layout from '@theme/Layout'; | ||
import TransformerTester from "../components/TransformerTester"; | ||
import BrowserOnly from "@docusaurus/BrowserOnly"; | ||
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; | ||
import preventResizeObserverError from "../components/hooks/preventResizeObserverError"; | ||
|
||
const LazyBrowserLayout = lazy(() => import("../components/TransformerTester")) | ||
|
||
const playground = () => { | ||
return <Layout> | ||
<div className="container" style={{ | ||
// @ts-ignore | ||
"--ifm-container-width-xl": "1600px" | ||
}}> | ||
<br/> | ||
<h1>Playground</h1> | ||
<p>Here you can test transformers yourself...</p> | ||
<TransformerTester /> | ||
</div> | ||
</Layout> | ||
|
||
if (ExecutionEnvironment.canUseDOM) { | ||
preventResizeObserverError(); | ||
} | ||
|
||
return ( | ||
<Layout> | ||
<div className="container" style={{ | ||
// @ts-ignore | ||
"--ifm-container-width-xl": "1600px" | ||
}}> | ||
<br/> | ||
<h1>Playground</h1> | ||
<p>Here you can test transformers yourself...</p> | ||
<BrowserOnly fallback={<div>Client-Only</div>}> | ||
{() => <LazyBrowserLayout />} | ||
</BrowserOnly> | ||
</div> | ||
</Layout> | ||
); | ||
} | ||
|
||
export default playground; |