Conversation
ynonp
left a comment
There was a problem hiding this comment.
Good and quick work.
I think I noticed a logic error in the implementation - In that the rate calculation is discrete. What I mean by that is consider I clicked 10 times within the second half of a second.
In the beginning of the next second my rate is zero, even though I just clicked like crazy and it sky rocketed just a few milliseconds earlier.
It would be nice to show the rate in a "window" of "the last second", in every point in time
| } | ||
|
|
||
|
|
||
| componentWillMount = () => { |
There was a problem hiding this comment.
Don't use componentWillMount. Ever. Everything you want to write here is better written in the constructor or in componentDidMount.
(If it uses the DOM it should be in componentDidMount. Otherwise in constructor)
|
|
||
|
|
||
| componentWillMount = () => { | ||
| this.timer = setInterval(() => { |
There was a problem hiding this comment.
This should certainly be in componentDidMount
| <button onClick={this.count} >Click Fast</button> | ||
| <p>CPS rate: {this.state.rate}</p> | ||
| <p>{this.state.rate > 4 ? "not so fast..." : "faster"}</p> | ||
| <Rect color={this.state.rate > 4 ? "green" : "red"}/> |
There was a problem hiding this comment.
Personally I would prefer to pass to Rect the current rate and let it decide on the color. But that may be a matter of taste.
No description provided.