Skip to content

Commit

Permalink
fix: investigating scroll issue (#1094)
Browse files Browse the repository at this point in the history
* investigating scroll issue

* style: Change template from 'react' to 'static' and update useClient.ts to handle conditional logic

* fix: Fix mapping issue
  • Loading branch information
danilowoz authored Feb 27, 2024
1 parent fbc7cc4 commit b994287
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 36 deletions.
46 changes: 12 additions & 34 deletions sandpack-react/src/Playground.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import * as themes from "@codesandbox/sandpack-themes";
import React from "react";

import { Sandpack } from "./";
Expand All @@ -9,37 +8,16 @@ export default {
};

export const Basic: React.FC = () => {
return <Sandpack template="react" theme={themes.sandpackDark} />;
return (
<>
{new Array(10).fill(null).map((_, index) => (
<Sandpack
options={{
initMode: "user-visible",
}}
template="static"
/>
))}
</>
);
};

export const EslintBasic = () => (
<Sandpack
files={{
"/.eslintrc.js": `module.exports = {
rules: {
"no-unused-vars": "error",
"no-console": "error",
},
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module'
},
}`,
"/index.js": `const helloWorld = "";
console.log("foo");`,

"/package.json": JSON.stringify({
devDependencies: {
eslint: "^8.0.1",
},
scripts: { start: "eslint index.js" },
}),
}}
options={{
visibleFiles: ["/index.js", "/.eslintrc.js"],
showConsole: true,
}}
template="node"
/>
);
4 changes: 2 additions & 2 deletions sandpack-react/src/contexts/utils/useClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ export const useClient: UseClient = (
client.iframe.contentWindow?.location.replace("about:blank");
client.iframe.removeAttribute("src");
delete clients.current[clientId];
} else {
delete registeredIframes.current[clientId];
}

delete registeredIframes.current[clientId];

if (timeoutHook.current) {
clearTimeout(timeoutHook.current);
}
Expand Down

0 comments on commit b994287

Please sign in to comment.