Skip to content

Commit

Permalink
fix(playground): run code even if it doesn't change
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Dec 2, 2024
1 parent 78c4077 commit 9de79f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/src/playground/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export default function Playground() {
const [initialContent, setInitialContent] = useState<EditorContent | null>(
null
);
const [runCount, setRunCount] = useState(1);
let { data: initialCode } = useSWRImmutable<EditorContent>(
!stateParam && !shared && gistId
? `/api/v1/play/${encodeURIComponent(gistId)}`
Expand Down Expand Up @@ -134,10 +135,13 @@ export default function Playground() {
);
setVConsole([]);
url.searchParams.set("state", state);
// ensure iframe reloads even if code doesn't change
url.searchParams.set("r", runCount.toString());
url.pathname = `${codeSrc || code.src || ""}/runner.html`;
setIframeSrc(url.href);
setRunCount(runCount + 1);
},
[codeSrc, setVConsole, setIframeSrc]
[codeSrc, setVConsole, setIframeSrc, runCount, setRunCount]
);

useEffect(() => {
Expand Down

0 comments on commit 9de79f9

Please sign in to comment.