@@ -36,6 +36,12 @@ export function WorkspacePanel({ tutorialStore, theme }: Props) {
36
36
const hasPreviews = tutorialStore . hasPreviews ( ) ;
37
37
const hideTerminalPanel = ! tutorialStore . hasTerminalPanel ( ) ;
38
38
39
+ /**
40
+ * Re-render when lesson changes. Some children are accessing non-reactive properties of store,
41
+ * so we need to re-render whole application in order to get those stale references updated.
42
+ */
43
+ useStore ( tutorialStore . ref ) ;
44
+
39
45
const terminalPanelRef = useRef < ImperativePanelHandle > ( null ) ;
40
46
const terminalExpanded = useRef ( false ) ;
41
47
@@ -89,6 +95,7 @@ function EditorSection({ theme, tutorialStore, hasEditor }: PanelProps) {
89
95
const selectedFile = useStore ( tutorialStore . selectedFile ) ;
90
96
const currentDocument = useStore ( tutorialStore . currentDocument ) ;
91
97
const lessonFullyLoaded = useStore ( tutorialStore . lessonFullyLoaded ) ;
98
+ const storeRef = useStore ( tutorialStore . ref ) ;
92
99
93
100
const lesson = tutorialStore . lesson ! ;
94
101
@@ -116,7 +123,7 @@ function EditorSection({ theme, tutorialStore, hasEditor }: PanelProps) {
116
123
} else {
117
124
setHelpAction ( 'reset' ) ;
118
125
}
119
- } , [ tutorialStore . ref ] ) ;
126
+ } , [ storeRef ] ) ;
120
127
121
128
return (
122
129
< Panel
@@ -128,7 +135,7 @@ function EditorSection({ theme, tutorialStore, hasEditor }: PanelProps) {
128
135
className = "transition-theme bg-tk-elements-panel-backgroundColor text-tk-elements-panel-textColor"
129
136
>
130
137
< EditorPanel
131
- id = { tutorialStore . ref }
138
+ id = { storeRef }
132
139
theme = { theme }
133
140
showFileTree = { tutorialStore . hasFileTree ( ) }
134
141
editorDocument = { currentDocument }
@@ -157,6 +164,7 @@ function PreviewsSection({
157
164
const previewRef = useRef < ImperativePreviewHandle > ( null ) ;
158
165
const lesson = tutorialStore . lesson ! ;
159
166
const terminalConfig = useStore ( tutorialStore . terminalConfig ) ;
167
+ const storeRef = useStore ( tutorialStore . ref ) ;
160
168
161
169
function showTerminal ( ) {
162
170
const { current : terminal } = terminalPanelRef ;
@@ -206,7 +214,7 @@ function PreviewsSection({
206
214
} ) ;
207
215
208
216
return ( ) => unsubscribe ( ) ;
209
- } , [ tutorialStore . ref ] ) ;
217
+ } , [ storeRef ] ) ;
210
218
211
219
return (
212
220
< Panel
0 commit comments