TS React synchronize anynonmous function behaves weird

Viewed 21

I'm experiencing a weird bug in my TS react application.

Similar code to mine:

   let spline: Spline = this.state.spline.copy(); // custom deep copy.
   console.log(spline);

This will work as expected.

If I changed the code to:

let spline: Spline = this.state.spline.copy();
console.log(spline);
spline.addCurve();

It seems that the addCurve function will run before the print, an unexpected behavior from synchronize anonymous function.

BTW this is how I declared the function:

class Foo extends Component {
  handleClick = () => {
    // the function.
  }
}
0 Answers
Related