-
Notifications
You must be signed in to change notification settings - Fork 86
fix(react): stale lesson data after navigation #318
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
Conversation
|
/pkg-pr-new |
e8df55f
to
dea6330
Compare
const hasEditor = tutorialStore.hasEditor(); | ||
const hasPreviews = tutorialStore.hasPreviews(); | ||
const hideTerminalPanel = !tutorialStore.hasTerminalPanel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we should make these reactive instead, e.g.
const hasEditor = useStore(tutorialStore.hasEditor);
... but as that would require quite much refactoring on the store, e.g. making lesson
reactive, I'd leave that out side of this PR.
@Nemikolh we have a failing minimal test case now! 🎉 🎉 After yesterday's extensive debugging session I realized what the root cause actually was. The tutorialkit/packages/react/src/Panels/WorkspacePanel.tsx Lines 35 to 37 in 1eb41fd
And as I tried to make |
Good work on the test! 🤩 Sounds good for the rest! I will review this ASAP. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
In #253 the amount of "unnecessary" re-renders were reduced by moving state to components where it was actually needed.
It turns out, those re-renders were indeed needed as
<WorkspacePanel />
is accessing non-reactive references of thetutorialStore
instead of reactive ones. This is not easily visible from the code though. We should improve that part later. This is now just a quick fix for the high priority bug.These are the non-reactive methods of
tutorialStore
that use stale data:tutorialkit/packages/react/src/Panels/WorkspacePanel.tsx
Lines 35 to 37 in 1eb41fd
Failing test case on CI: https://github.com/stackblitz/tutorialkit/actions/runs/10733493214/job/29766948087?pr=318
Before:
tk-layout-after-nav-bug.webm
After:
tk-layout-after-nav-fixed.webm