🤑 Join the Treehouse affiliate program and earn 25% recurring commission!

New No-Code Track! 🚀start learning today!

🌟 Dreaming of a bright future? 🎓 Ask about the Treehouse Scholarship program! 🚀

✨ Earn college credits in Cybersecurity, JS, HTML, CSS and Python

  • Treehouse Logo
  • Plans
    Chevron
    • For Individuals
    • For Businesses
    • For Schools
    • For Libraries
    • For Military
  • Library
    Chevron
    • All Courses
    • Tracks
    • College Credit
  • Techdegree
    Chevron
    • Overview
    • Front End Development
    • Full Stack JavaScript
    • Data Analysis
    • UX Design
    • Python
  • Community
    Chevron
    • Code Adventures
    • Discord
    • Forum
    • Success Stories
    • Treehouse Links
    • 100 Days of Code
  • Resources
    Chevron
    • Career Toolbox
    • CodeForward
    • Free Treehouse Near Me
    • Jobs
    • Blog
    • Support
    • About
  • For Individuals For Businesses For Schools For Libraries For Military
  • All Courses Tracks College Credit
  • Overview Front End Web Development Full Stack JavaScript Python Development Data Analysis UX Design
  • Code Adventures Discord Forum Success Stories Treehouse Links 100 Days of Code
  • Career Toolbox CodeForward Free Treehouse Near Me Jobs Blog Support About
  • Sign In
  • Free Trial
Instagram Twitter Facebook YouTube LinkedIn
    • Newest
      • Newest
      • Active
      • Unanswered
      • Featured
    • All Topics
      • All Topics
      • • General Discussion
      • • AI
      • • Android
      • • APIs
      • • Coding for Kids
      • • College Credit
      • • Computer Science
      • • CSS
      • • Data Analysis
      • • Databases
      • • Design
      • • Development Tools
      • • Digital Literacy
      • • Game Development
      • • Go Language
      • • HTML
      • • Java
      • • JavaScript
      • • Learning Resources
      • • Machine Learning
      • • No-Code
      • • PHP
      • • Professional Growth
      • • Python
      • • Quality Assurance
      • • React
      • • Ruby
      • • Security
      • • Swift
  • Alena Miadzvedskaya
    Alena Miadzvedskaya
    6,386 Points

    Can't stop the timer, it still ticks even after stop button was clicked

    Posted October 12, 2021 8:41pm by Alena Miadzvedskaya
    Alena Miadzvedskaya
    6,386 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Resetting the Stopwatch

    0 Answers

  • jun cheng wong
    jun cheng wong
    17,021 Points

    Need further explaination

    Posted June 5, 2021 6:53am by jun cheng wong
    jun cheng wong
    17,021 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • jun cheng wong
    jun cheng wong
    17,021 Points

    Using ternary for handleStopwatch

    Posted June 5, 2021 5:27am by jun cheng wong
    jun cheng wong
    17,021 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Stopwatch State

    0 Answers

  • Eduardo Osorio
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    Eduardo Osorio
    Full Stack JavaScript Techdegree Graduate 20,847 Points

    Why is he calling this.tick() inside set interval instead of just passing it as a callback ie: this.tick ?

    Posted March 12, 2021 9:50pm by Eduardo Osorio
    .a{fill-rule:evenodd;}techdegree seal-36
    Eduardo Osorio
    Full Stack JavaScript Techdegree Graduate 20,847 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • Nancy Melucci
    PLUS
    Nancy Melucci
    Courses Plus Student 36,159 Points

    handleReset breaks the program

    Posted December 24, 2020 3:34pm by Nancy Melucci
    Nancy Melucci
    Courses Plus Student 36,159 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Resetting the Stopwatch

    2 Answers

  • cloud712
    cloud712
    7,616 Points

    Silly question but why is the onClick attribute set to "this.handleStopwatch" and not "this.state.handleStopwatch"?

    Posted November 27, 2020 7:29pm by cloud712
    cloud712
    7,616 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Stopwatch State

    1 Answer

  • Shung Chen
    Shung Chen
    6,526 Points

    Confusion in getting true elapsedTime

    Posted September 25, 2020 5:34pm by Shung Chen
    Shung Chen
    6,526 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    0 Answers

  • Yanhan Liu
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    Yanhan Liu
    Front End Web Development Techdegree Graduate 16,389 Points

    React | Why add () when using prevState in setState()?

    Posted September 25, 2020 4:28pm by Yanhan Liu
    .a{fill-rule:evenodd;}techdegree seal-36
    Yanhan Liu
    Front End Web Development Techdegree Graduate 16,389 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • disheng wang
    disheng wang
    5,422 Points

    Question about the arguments passing in to the setInterval method

    Posted August 6, 2020 2:57am by disheng wang
    disheng wang
    5,422 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Prevent Memory Leaks with componentWillUnmount()

    0 Answers

  • Elroyi Ben david
    Elroyi Ben david
    188 Points

    transform this comppnante class to hooks...it dosent work why?

    Posted July 15, 2020 10:17am by Elroyi Ben david
    Elroyi Ben david
    188 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Prevent Memory Leaks with componentWillUnmount()

    0 Answers

  • Begana Choi
    PLUS
    Begana Choi
    Courses Plus Student 13,126 Points

    why don't we use prevState in tick function for ( now - this.state.previousTime )?

    Posted June 14, 2020 10:55am by Begana Choi
    Begana Choi
    Courses Plus Student 13,126 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • virus200
    virus200
    6,583 Points

    Interval/Timeout throttling for timer?

    Posted March 17, 2020 3:31pm by virus200
    virus200
    6,583 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    0 Answers

  • onesoftwareengineer
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    onesoftwareengineer
    Full Stack JavaScript Techdegree Graduate 19,767 Points

    Might the asynchronous setState() method be run before the next segment of synchronous code in some instances ?

    Posted January 27, 2020 12:09pm by onesoftwareengineer
    .a{fill-rule:evenodd;}techdegree seal-36
    onesoftwareengineer
    Full Stack JavaScript Techdegree Graduate 19,767 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • Christopher Johnson
    Christopher Johnson
    12,595 Points

    How do I recreate the memory leak in the console prior to unmounting (as shown)?

    Posted January 21, 2020 8:27pm by Christopher Johnson
    Christopher Johnson
    12,595 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Prevent Memory Leaks with componentWillUnmount()

    0 Answers

  • Herman Morales
    Herman Morales
    8,831 Points

    Why did you use the this.intervalID instead a only a setInterval and where is the intervalID property? never wasdeclared

    Posted November 6, 2019 1:58am by Herman Morales
    Herman Morales
    8,831 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    0 Answers

  • Ankit Upadhyay
    Ankit Upadhyay
    556 Points

    Update the Stopwatch

    Posted August 13, 2019 1:49pm by Ankit Upadhyay
    Ankit Upadhyay
    556 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    0 Answers

  • vamosrope14
    vamosrope14
    14,932 Points

    Can someone please explain the concept behind elapsedTime and previousTime?

    Posted August 13, 2019 1:17am by vamosrope14
    vamosrope14
    14,932 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • Luke Markham
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    Luke Markham
    Front End Web Development Techdegree Graduate 17,289 Points

    timer reset with first "console.log('starting')"

    Posted June 22, 2019 2:07am by Luke Markham
    .a{fill-rule:evenodd;}techdegree seal-36
    Luke Markham
    Front End Web Development Techdegree Graduate 17,289 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • gerardo keys
    gerardo keys
    14,292 Points

    Am I understanding this correctly?

    Posted June 14, 2019 12:50am by gerardo keys
    gerardo keys
    14,292 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Prevent Memory Leaks with componentWillUnmount()

    0 Answers

  • Unsubscribed User
    PLUS
    Unsubscribed User
    Courses Plus Student 112 Points

    Complete the code to add the method that will clear the interval ID once the component gets removed from the DOM.

    Posted May 19, 2019 7:50pm by Unsubscribed User
    Unsubscribed User
    Courses Plus Student 112 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Stateful Components and Lifecycle Methods Review

    2 Answers

  • Unsubscribed User
    PLUS
    Unsubscribed User
    Courses Plus Student 112 Points

    please fill correct answer , isLogIn state ?

    Posted May 19, 2019 4:32pm by Unsubscribed User
    Unsubscribed User
    Courses Plus Student 112 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Stateful Components and Lifecycle Methods Review

    1 Answer

  • Ran Wang
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    Ran Wang
    Full Stack JavaScript Techdegree Graduate 32,191 Points

    What is memory leak?

    Posted March 24, 2019 3:37pm by Ran Wang
    .a{fill-rule:evenodd;}techdegree seal-36
    Ran Wang
    Full Stack JavaScript Techdegree Graduate 32,191 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Prevent Memory Leaks with componentWillUnmount()

    2 Answers

  • ewenearle
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    ewenearle
    Full Stack JavaScript Techdegree Graduate 18,744 Points

    setInterval() inside componentDidMount()

    Posted March 5, 2019 4:58pm by ewenearle
    .a{fill-rule:evenodd;}techdegree seal-36
    ewenearle
    Full Stack JavaScript Techdegree Graduate 18,744 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • Janaka Bandara
    Janaka Bandara
    1,329 Points

    When you store seconds in a const, how come that value gets changed? Isn't const an immutable (for primitive) in ES2015?

    Posted January 8, 2019 6:23am by Janaka Bandara
    Janaka Bandara
    1,329 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Resetting the Stopwatch

    3 Answers

  • Brian Hoang
    Brian Hoang
    11,515 Points

    setState in handleStopwatch()

    Posted November 13, 2018 1:37pm by Brian Hoang
    Brian Hoang
    11,515 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    1 Answer

  • Jose Morales-Mendizabal
    Jose Morales-Mendizabal
    19,175 Points

    Why not call Tick() every 1000ms instead of doing the Math?

    Posted November 6, 2018 5:40pm by Jose Morales-Mendizabal
    Jose Morales-Mendizabal
    19,175 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Resetting the Stopwatch

    1 Answer

  • Saud Tauqeer
    PLUS
    Saud Tauqeer
    Courses Plus Student 8,099 Points

    Having trouble understanding logic.

    Posted October 11, 2018 1:22am by Saud Tauqeer
    Saud Tauqeer
    Courses Plus Student 8,099 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Update the Stopwatch State with componentDidMount()

    2 Answers

  • Chris Holder
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    Chris Holder
    Full Stack JavaScript Techdegree Graduate 19,841 Points

    Why don't we mutate prevState instead of this.state when we change the value of isRunning?

    Posted October 10, 2018 1:44am by Chris Holder
    .a{fill-rule:evenodd;}techdegree seal-36
    Chris Holder
    Full Stack JavaScript Techdegree Graduate 19,841 Points
    • JavaScript
    • React Components (2018)
    • Stateful Components and Lifecycle Methods
    • Stopwatch State

    1 Answer

Posting to the forum is only allowed for members with active accounts.
Please sign in or sign up to post.

    Treehouse

  • About
  • Blog
  • Careers
  • Community
  • Stories
  • Shop
  • Contact
  • Gift Card

See Full Catalogue

Techdegree

  • Front End Web Development
  • Full Stack JavaScript
  • Python Development
  • Data Analysis
  • UX Design

Tracks

  • Learn to Code for Beginners
  • Beginning Python
  • Beginning SQL
  • Beginning Java
  • ...see more

Courses

  • JavaScript Basics
  • Intro to HTML & CSS
  • Python Basics
  • CSS Layout
  • ...see more

Explore

  • Plans
  • Affiliates
  • Perks
  • Free Treehouse Near Me
  • Treehouse for Libraries
  • Treehouse for Businesses
  • Twitter
  • YouTube
  • Facebook
  • LinkedIn
  • Instagram
Terms & Conditions | Privacy

© 2025 Treehouse Island, Inc.