diff --git a/sandpack-react/src/components/Preview/index.tsx b/sandpack-react/src/components/Preview/index.tsx
index 73e5bdb4f..a4fb81ac4 100644
--- a/sandpack-react/src/components/Preview/index.tsx
+++ b/sandpack-react/src/components/Preview/index.tsx
@@ -105,7 +105,6 @@ export const SandpackPreview = ({
customStyle={{
...customStyle,
...viewportStyle,
- display: status !== "idle" ? "flex" : "none",
}}
>
{showNavigator ? (
diff --git a/sandpack-react/src/contexts/sandpackContext.tsx b/sandpack-react/src/contexts/sandpackContext.tsx
index 99a17d961..a8a97a076 100644
--- a/sandpack-react/src/contexts/sandpackContext.tsx
+++ b/sandpack-react/src/contexts/sandpackContext.tsx
@@ -256,7 +256,7 @@ class SandpackProvider extends React.PureComponent<
const observerOptions = {
rootMargin: "600px 0px",
- threshold: 0.2,
+ threshold: 0.4,
};
if (this.intersectionObserver && this.lazyAnchorRef.current) {
@@ -484,6 +484,8 @@ class SandpackProvider extends React.PureComponent<
} else {
delete this.preregisteredIframes[clientId];
}
+
+ this.setState({ sandpackStatus: "idle" });
};
/**
diff --git a/sandpack-react/src/hooks/useLoadingOverlayState.ts b/sandpack-react/src/hooks/useLoadingOverlayState.ts
index b73052bcf..62f41e644 100644
--- a/sandpack-react/src/hooks/useLoadingOverlayState.ts
+++ b/sandpack-react/src/hooks/useLoadingOverlayState.ts
@@ -45,8 +45,7 @@ export const useLoadingOverlayState = (
clearTimeout(innerHook);
unsub();
};
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, []);
+ }, [clientId, sandpack.status === "idle"]);
if (sandpack.status === "timeout") {
return "timeout";
diff --git a/sandpack-react/src/presets/Playground.stories.tsx b/sandpack-react/src/presets/Playground.stories.tsx
index 341fded60..325a646ac 100644
--- a/sandpack-react/src/presets/Playground.stories.tsx
+++ b/sandpack-react/src/presets/Playground.stories.tsx
@@ -1,95 +1,27 @@
import {
+ Sandpack,
+ SandpackPreview,
SandpackProvider,
- SandpackCodeViewer,
- SandpackThemeProvider,
+ SandpackLayout,
} from "../";
export default {
title: "Playground",
};
-const decorators = [
- { className: "highlight", line: 1 },
- { className: "highlight", line: 9 },
- {
- className: "widget",
- elementAttributes: { "data-id": "1" },
- line: 12,
- startColumn: 26,
- endColumn: 38,
- },
- {
- className: "widget",
- elementAttributes: { "data-id": "2" },
- line: 13,
- startColumn: 8,
- endColumn: 17,
- },
-];
-
export const Main = (): JSX.Element => {
return (
<>
-
-
- {listItems}
;
-}`,
- },
- }}
- >
-