Skip to content

Commit 745be37

Browse files
authored
fix(astro): don't modify state during re-renders of <WorkspacePanelWrapper /> (#240)
1 parent 9bf2156 commit 745be37

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

packages/astro/src/default/components/WorkspacePanelWrapper.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useEffect } from 'react';
12
import { useStore } from '@nanostores/react';
23
import { WorkspacePanel } from '@tutorialkit/components-react';
34
import type { Lesson } from '@tutorialkit/types';
@@ -11,7 +12,13 @@ interface Props {
1112
export function WorkspacePanelWrapper({ lesson }: Props) {
1213
const theme = useStore(themeStore);
1314

14-
tutorialStore.setLesson(lesson, { ssr: import.meta.env.SSR });
15+
useEffect(() => {
16+
tutorialStore.setLesson(lesson);
17+
}, [lesson]);
18+
19+
if (import.meta.env.SSR || !tutorialStore.lesson) {
20+
tutorialStore.setLesson(lesson, { ssr: import.meta.env.SSR });
21+
}
1522

1623
return <WorkspacePanel tutorialStore={tutorialStore} theme={theme} />;
1724
}

packages/components/react/src/Panels/PreviewPanel.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export const PreviewPanel = memo(
134134
return createElement(PanelGroup, { id: 'preview-panel', direction: 'horizontal' }, ...children);
135135
}),
136136
);
137+
PreviewPanel.displayName = 'PreviewPanel';
137138

138139
interface PreviewProps {
139140
iframe: IFrameRef;

packages/components/react/src/core/Terminal/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,5 @@ export const Terminal = forwardRef<TerminalRef, TerminalProps>(
8383
},
8484
);
8585

86+
Terminal.displayName = 'Terminal';
8687
export default Terminal;

0 commit comments

Comments
 (0)