pughpugh / react-countdown-clock

HTML5 canvas countdown clock React component
ISC License
187 stars 83 forks source link

Uncaught TypeError: Cannot read property 'width' of undefined at Object._clearTimer #34

Closed ghost closed 6 years ago

ghost commented 7 years ago

I'm getting this error

Uncaught TypeError: Cannot read property 'width' of undefined
    at Object._clearTimer

the problem is in this line: return this._timer.clearRect(0,0,this.refs.timer.width,this.refs.timer.height)

I solved it by adding condition

 if(typeof this.refs.timer !='undefined'){
  return this._timer.clearRect(0,0,this.refs.timer.width,this.refs.timer.height)
  }
melight402 commented 6 years ago

the same bug but in stateless component, how to fix it there?

chabanov commented 6 years ago

Remove https://github.com/pughpugh/react-countdown-clock/blob/fef78f9a5f3f6185000269cce604c458d26f93ee/coffee/react-countdown-clock.coffee#L99

pegetive commented 6 years ago

Hi, I removed line 99 as mentioned above, but still receive this error.

pegetive commented 6 years ago

@jericbas In which file did you add the following condition?

 if(typeof this.refs.timer !='undefined'){
  return this._timer.clearRect(0,0,this.refs.timer.width,this.refs.timer.height)
  }
pughpugh commented 6 years ago

@pegative They may have edited the minified version manually or built it from scratch. Off the top of my head, the process from the CLI is as below.

git clone git@github.com:pughpugh/react-countdown-clock.git
cd react-countdown-clock
npm install

# edit coffee/react-countdown-clock.coffee as needed

# run webpack to build a production copy of the component
webpack -p

# the minified file will be available in ./build

I've not scheudled any time to work on this component at the moment, but I will update this issue if I find some time to work on it.

fmagaldea commented 6 years ago

Same issue, same request > I hope you will find the time to fix soon !

That said, nice component.

pughpugh commented 6 years ago

Thanks for all the input. This should be fixed in 2.3.0.