Skip to content

Commit 50fbbdb

Browse files
authored
fix(browser-repl): make sure we are actually using initial value of initialEvaluate (#2058)
1 parent 06085a7 commit 50fbbdb

File tree

1 file changed

+10
-7
lines changed
  • packages/browser-repl/src/components

1 file changed

+10
-7
lines changed

packages/browser-repl/src/components/shell.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,18 @@ export class Shell extends Component<ShellProps, ShellState> {
162162
};
163163

164164
componentDidMount(): void {
165+
// Store the intial prop value on mount so that we're not using potentially
166+
// updated one when actually running the lines
167+
let evalLines: string[] = [];
168+
if (this.props.initialEvaluate) {
169+
evalLines = Array.isArray(this.props.initialEvaluate)
170+
? this.props.initialEvaluate
171+
: [this.props.initialEvaluate];
172+
}
165173
this.scrollToBottom();
166174
void this.updateShellPrompt().then(async () => {
167-
if (this.props.initialEvaluate) {
168-
const evalLines = Array.isArray(this.props.initialEvaluate)
169-
? this.props.initialEvaluate
170-
: [this.props.initialEvaluate];
171-
for (const input of evalLines) {
172-
await this.onInput(input);
173-
}
175+
for (const input of evalLines) {
176+
await this.onInput(input);
174177
}
175178
});
176179
}

0 commit comments

Comments
 (0)