From 758494ab18ef319cde1aea20c2ebbc87d678aa78 Mon Sep 17 00:00:00 2001 From: Michael Taranto Date: Wed, 20 Jan 2021 10:09:17 +1100 Subject: [PATCH] fix: Render last valid code when current code is invalid (#212) --- src/Playroom/Frames/Frames.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Playroom/Frames/Frames.tsx b/src/Playroom/Frames/Frames.tsx index 5a06ffe6..2fd3b93d 100644 --- a/src/Playroom/Frames/Frames.tsx +++ b/src/Playroom/Frames/Frames.tsx @@ -17,6 +17,8 @@ interface FramesProps { widths: PlayroomProps['widths']; } +let renderCode = ''; + export default function Frames({ code, themes, widths }: FramesProps) { const scrollingPanelRef = useRef(null); @@ -28,13 +30,9 @@ export default function Frames({ code, themes, widths }: FramesProps) { })) ); - let renderCode = code; - try { renderCode = compileJsx(code); - } catch (e) { - renderCode = ''; - } + } catch (e) {} return (