willb335 / chessboardjsx

:black_square_button: Chessboard built for React
https://chessboardjsx.com
MIT License
267 stars 79 forks source link

Small bug in RandomVsRandom.componentWillUnmount #31

Closed furrykef closed 6 years ago

furrykef commented 6 years ago

RandomVsRandom.componentWillUnmount has the line window.clearTimeout(this.timer()). Surely that should be this.timer, without the parentheses? Here's a fixed version: https://codesandbox.io/s/9q198jzz3w

This bug also exists in the git repository.

willb335 commented 6 years ago
timer = () => window.setTimeout(this.makeRandomMove, 1000);
clearTimeout(timer())

timer is a function so I believe it's correct to call it with parenthesis

if it wasn't a function

timer = window.setTimeout(this.makeRandomMove, 1000);
clearTimeout(timer)
furrykef commented 6 years ago

Whoops, I completely misunderstood what's going on. Never mind! My apologies.