Skip to content

Commit

Permalink
fix(astro): don't modify state during re-renders of `<WorkspacePanelW…
Browse files Browse the repository at this point in the history
…rapper />` (#240)
  • Loading branch information
AriPerkkio authored Aug 13, 2024
1 parent 9bf2156 commit 745be37
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from 'react';
import { useStore } from '@nanostores/react';
import { WorkspacePanel } from '@tutorialkit/components-react';
import type { Lesson } from '@tutorialkit/types';
Expand All @@ -11,7 +12,13 @@ interface Props {
export function WorkspacePanelWrapper({ lesson }: Props) {
const theme = useStore(themeStore);

tutorialStore.setLesson(lesson, { ssr: import.meta.env.SSR });
useEffect(() => {
tutorialStore.setLesson(lesson);
}, [lesson]);

if (import.meta.env.SSR || !tutorialStore.lesson) {
tutorialStore.setLesson(lesson, { ssr: import.meta.env.SSR });
}

return <WorkspacePanel tutorialStore={tutorialStore} theme={theme} />;
}
1 change: 1 addition & 0 deletions packages/components/react/src/Panels/PreviewPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export const PreviewPanel = memo(
return createElement(PanelGroup, { id: 'preview-panel', direction: 'horizontal' }, ...children);
}),
);
PreviewPanel.displayName = 'PreviewPanel';

interface PreviewProps {
iframe: IFrameRef;
Expand Down
1 change: 1 addition & 0 deletions packages/components/react/src/core/Terminal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,5 @@ export const Terminal = forwardRef<TerminalRef, TerminalProps>(
},
);

Terminal.displayName = 'Terminal';
export default Terminal;

0 comments on commit 745be37

Please sign in to comment.