Skip to content

Commit

Permalink
fix: Render last valid code when current code is invalid (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltaranto committed Jan 19, 2021
1 parent 5230140 commit 758494a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/Playroom/Frames/Frames.tsx
Expand Up @@ -17,6 +17,8 @@ interface FramesProps {
widths: PlayroomProps['widths'];
}

let renderCode = '<React.Fragment></React.Fragment>';

export default function Frames({ code, themes, widths }: FramesProps) {
const scrollingPanelRef = useRef<HTMLDivElement | null>(null);

Expand All @@ -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 (
<div ref={scrollingPanelRef} className={styles.root}>
Expand Down

0 comments on commit 758494a

Please sign in to comment.