diff --git a/beta/src/components/MDX/Sandpack/DownloadButton.tsx b/beta/src/components/MDX/Sandpack/DownloadButton.tsx index 1404aaae..dfec93d0 100644 --- a/beta/src/components/MDX/Sandpack/DownloadButton.tsx +++ b/beta/src/components/MDX/Sandpack/DownloadButton.tsx @@ -7,18 +7,22 @@ import {useSandpack} from '@codesandbox/sandpack-react'; import {IconArrowSmall} from '../../Icon/IconArrowSmall'; export interface DownloadButtonProps {} +let initialIsSupported = false; + export const DownloadButton: React.FC = () => { const {sandpack} = useSandpack(); - const [supported, setSupported] = React.useState(false); + const [supported, setSupported] = React.useState(initialIsSupported); React.useEffect(() => { // This detection will work in Chrome 97+ if ( + !supported && (HTMLScriptElement as any).supports && (HTMLScriptElement as any).supports('importmap') ) { setSupported(true); + initialIsSupported = true; } - }, []); + }, [supported]); if (!supported) { return null;