Please Teach Me#1
Open
rustyneuron01 wants to merge 2 commits into
Open
Conversation
| setTime((time) => time + 10); | ||
| }, 10); | ||
| } else { | ||
|
|
There was a problem hiding this comment.
It's not to bad to leave blank here but it doesn't seem good as well.
| setTime(0); | ||
| interval.current = null; | ||
| } | ||
|
|
| function StopWatch() { | ||
| const [isActived, setIsActived] = useState(false); | ||
| const [isPaused, setIsPaused] = useState(true); | ||
| const [isActived, setIsActived] = useState(false); // For Check Press Reset Button |
There was a problem hiding this comment.
Since the variable name is isActive, it actually means whether the timer is active or not.
There's a saying "Code itself is a comment"
| const [isActived, setIsActived] = useState(false); | ||
| const [isPaused, setIsPaused] = useState(true); | ||
| const [isActived, setIsActived] = useState(false); // For Check Press Reset Button | ||
| const [isPaused, setIsPaused] = useState(true); // For Check Pause |
There was a problem hiding this comment.
Same here. I have no idea why we need isPaused,
We can just have isActive (isActived is a wrong name) state. And if a user click 'Reset', you just need to set isActive as false and timer as zero.
|
We're getting closer. Let's fix again. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please Teach Me