-2

I want my code to wait 500 milliseconds before performing the next step.

I've used setTimeout but it doesn't work.

updateDisplay = arr => {
  setTimeout(function () {
    this.setState({ sortArray: arr });
  }, 500);
};
michael
  • 4,053
  • 2
  • 12
  • 31
Golden
  • 3
  • 1

1 Answers1

0

Some simple incorrect syntax.

updateDisplay = (arr) => {
  setTimeout(() => this.setState({ sortArray: arr }), 500);
};

justahuman
  • 607
  • 4
  • 13