Skip to content

fix(astro): don't modify state during re-renders of <WorkspacePanelWrapper /> #240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

AriPerkkio
Copy link
Member

Fixes React's state warning that happen when navigating between pages. setLesson that's done inside rendering block attempts to update state of the components that are just about to unmount.

Warning: Cannot update a component (`PreviewPanel`) while rendering a different component (`WorkspacePanelWrapper`). To locate the bad setState() call inside `WorkspacePanelWrapper`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render
    at WorkspacePanelWrapper (http://localhost:4321/@fs/Users/x/tutorialkit/packages/astro/dist/default/components/WorkspacePanelWrapper.tsx:23:41)

printWarning                        @    react-dom.development.js:86
error                               @    react-dom.development.js:60
warnAboutRenderPhaseUpdatesInDEV    @    react-dom.development.js:27531
scheduleUpdateOnFiber               @    react-dom.development.js:25537
forceStoreRerender                  @    react-dom.development.js:16158
handleStoreChange                   @    react-dom.development.js:16134
notify                              @    index.js:55
set                                 @    index.js:72
setPreviews                         @    previews.js:77
setLesson                           @    index.js:96
WorkspacePanelWrapper               @    WorkspacePanelWrapper.tsx:15

Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Member

@Nemikolh Nemikolh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just a minor comment 👍

Copy link
Member

@Nemikolh Nemikolh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! 🤩

@Nemikolh Nemikolh merged commit 745be37 into stackblitz:main Aug 13, 2024
9 checks passed
@AriPerkkio AriPerkkio deleted the fix/state-update-during-render branch August 14, 2024 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants