From 2b3b3f4d4429c7e4bdf48dbb098391c9a484cb9d Mon Sep 17 00:00:00 2001 From: samya123456 Date: Mon, 20 Nov 2023 18:31:00 +0530 Subject: [PATCH 01/21] adding some git ignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 39aee32..1ea457d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ # Run logs backend/run_logs/* - +backend/backend/* +frontend/.env.local .env \ No newline at end of file From 9dfdc8683d114d09d69b84ae5b9a8e823ce0bd0e Mon Sep 17 00:00:00 2001 From: clean99 Date: Tue, 21 Nov 2023 09:23:07 +0800 Subject: [PATCH 02/21] fix: prevent flashing when updating code --- frontend/src/components/Preview.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Preview.tsx b/frontend/src/components/Preview.tsx index de0134f..3a603ff 100644 --- a/frontend/src/components/Preview.tsx +++ b/frontend/src/components/Preview.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef } from 'react'; import classNames from "classnames"; import useThrottle from "../hooks/useThrottle"; @@ -8,12 +9,22 @@ interface Props { function Preview({ code, device }: Props) { const throttledCode = useThrottle(code, 200); + const iframeRef = useRef(null); + + useEffect(() => { + const iframe = iframeRef.current; + if (iframe && iframe.contentDocument) { + iframe.contentDocument.open(); + iframe.contentDocument.write(throttledCode); + iframe.contentDocument.close(); + } + }, [throttledCode]); return (