Skip to main content

🚀 In our NEW AI Bootcamp you'll build a working app in 28 days, no experience required. Free to all subscription levels.

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

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

  • Treehouse Logo
    • For Individuals
    • For Businesses
    • For Schools
    • For Libraries
    • For Military
    • All Courses
    • Tracks
    • AI Bootcamp
    • College Credit
    • Techdegree Bootcamps
    • Front End Development
    • Full Stack JavaScript
    • Code Adventures
    • Discord
    • Forum
    • Success Stories
    • Treehouse Links
    • 100 Days of Code
    • Explore
    • Career Toolbox
    • Free Treehouse Near Me
    • Affiliates
    • Blog
    • Support
    • About
    • Learn
    • Beginner's Guide to Coding
    • Data Analysis with SQL & Python
    • Front-End Web Development
    • Python Programming Basics
    • Techdegree Bootcamp Overview
    • UX Design Fundamentals
    • AI Tools for Beginners
  • For Individuals For Businesses For Schools For Libraries For Military
  • All Courses Tracks AI Bootcamp College Credit
  • Techdegree Bootcamps Front End Web Development Full Stack JavaScript
  • Code Adventures Discord Forum Success Stories Treehouse Links 100 Days of Code
  • Explore Career Toolbox Free Treehouse Near Me Affiliates Blog Support About
    Learn Beginner's Guide to Coding Data Analysis with SQL & Python Front-End Web Development Python Programming Basics Techdegree Bootcamp Overview UX Design Fundamentals AI Tools for Beginners
  • Sign In
  • Free Trial
Instagram Twitter Facebook YouTube LinkedIn
Loading banner... Start your free trial at Treehouse
    • Newest
      • Newest
      • Active
      • Unanswered
      • Featured
    • All Topics
      • All Topics
      • • General Discussion
      • • AI
      • • 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
      • • Vibe Coding
  • 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

  • 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

  • Shung Chen
    Shung Chen
    6,527 Points

    Confusion in getting true elapsedTime

    Posted September 25, 2020 5:34pm by Shung Chen
    Shung Chen
    6,527 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

  • 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

  • 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

  • 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

  • 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

  • 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

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

Techdegree

  • Front End Web Development
  • Full Stack JavaScript
SEE ALL

Tracks

  • Learn to Code for Beginners
  • Beginning Python
  • Beginning SQL
  • Beginning Java
SEE ALL

Courses

  • JavaScript Basics
  • Intro to HTML & CSS
  • Python Basics
  • CSS Layout
SEE ALL

About Us

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

Explore

  • Plans
  • Affiliates
  • Perks
  • Shop
  • Free Treehouse Near Me
  • Treehouse for Libraries
  • Treehouse for Businesses

Treehouse is an online technology education platform founded in 2011. Treehouse offers more than 700 self-paced, video-based courses in web development, programming, data analysis, design, and AI, plus two project-based bootcamp programs in Front End Web Development and Full Stack JavaScript. Individual Treehouse plans start at $25 per month and include a 7-day free trial. Treehouse serves individual learners, businesses, schools, and public libraries. Cardholders at participating U.S. public libraries can use Treehouse for free. Select Treehouse courses, offered with University Pathways International, are recommended for college credit by ACE and NCCRS. Treehouse learners earn digital certificates for completed Tracks.

Terms & Conditions · Privacy · © 2026 Treehouse Island, Inc.
  • Twitter
  • YouTube
  • Facebook
  • LinkedIn
  • Instagram
  • Discord