react-console-emulator icon indicating copy to clipboard operation
react-console-emulator copied to clipboard

pushToStdout function changes the state inplace

Open impulsgraw opened this issue 4 years ago • 0 comments

pushToStdout = (message, options) => {
  const { stdout } = this.state

  if (this.props.locked) stdout.pop()

  stdout.push({ message, isEcho: options?.isEcho || false })

  /* istanbul ignore next: Covered by interactivity tests */
  if (options?.rawInput) this.pushToHistory(options.rawInput)
  this.setState({ stdout: stdout })
}

Here the state object is being changed inplace, so setState does nothing. Probably it's minor, since I couldn't observe the bug.

impulsgraw avatar Mar 28 '21 20:03 impulsgraw