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
  • Rashad Nelson
    Rashad Nelson
    6,532 Points

    Curly braces

    Posted September 15, 2022 3:10am by Rashad Nelson
    Rashad Nelson
    6,532 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    1 Answer

  • Marcus Ducklow
    Marcus Ducklow
    1,978 Points

    VS code ignoring css?

    Posted June 21, 2020 4:47pm by Marcus Ducklow
    Marcus Ducklow
    1,978 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    1 Answer

  • Joseph Butterfield
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    Joseph Butterfield
    Full Stack JavaScript Techdegree Graduate 16,430 Points

    Why add the () outside the return statement when you omit the return {} syntax?

    Posted February 5, 2020 10:36pm by Joseph Butterfield
    .a{fill-rule:evenodd;}techdegree seal-36
    Joseph Butterfield
    Full Stack JavaScript Techdegree Graduate 16,430 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    1 Answer

  • Joseph Butterfield
    seal-mask
    .a{fill-rule:evenodd;}techdegree seal-36
    Joseph Butterfield
    Full Stack JavaScript Techdegree Graduate 16,430 Points

    How does prevState reference this.state before change?

    Posted February 5, 2020 10:16pm by Joseph Butterfield
    .a{fill-rule:evenodd;}techdegree seal-36
    Joseph Butterfield
    Full Stack JavaScript Techdegree Graduate 16,430 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    1 Answer

  • Rachel Heneault
    Rachel Heneault
    12,471 Points

    I'm confused why you'd use the callback when updating state? Seems like an extra step when it gave you the same results

    Posted October 24, 2019 10:38pm by Rachel Heneault
    Rachel Heneault
    12,471 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    3 Answers

  • lassek
    lassek
    8,209 Points

    Is my understanding of state handling correct?

    Posted October 22, 2019 11:08pm by lassek
    lassek
    8,209 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    0 Answers

  • ammarkhan
    seal-mask
    .a{fill-rule:evenodd;}techdegree
    ammarkhan
    Front End Web Development Techdegree Student 21,661 Points

    Why use prevState?

    Posted April 13, 2019 10:19am by ammarkhan
    .a{fill-rule:evenodd;}techdegree
    ammarkhan
    Front End Web Development Techdegree Student 21,661 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    1 Answer

  • Aakash Srivastav
    seal-mask
    .a{fill-rule:evenodd;}techdegree
    Aakash Srivastav
    Full Stack JavaScript Techdegree Student 184 Points

    Update state based on previous score

    Posted March 8, 2019 7:44am by Aakash Srivastav
    .a{fill-rule:evenodd;}techdegree
    Aakash Srivastav
    Full Stack JavaScript Techdegree Student 184 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    1 Answer

  • jlampstack
    jlampstack
    23,932 Points

    Why use {} curly braces for return inside setState() ?

    Posted February 17, 2019 12:49am by jlampstack
    jlampstack
    23,932 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    2 Answers

  • Samuel Marques
    Samuel Marques
    1,023 Points

    How to make the decrement not exceed 0?

    Posted October 4, 2018 4:32pm by Samuel Marques
    Samuel Marques
    1,023 Points
    • JavaScript
    • React Basics (2018)
    • Understanding State
    • Update State Based on Previous State

    3 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