Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
How setState provides previous state in React.Component

I have already checked the setState() and React.Component class source code of the React official document. Nevertheless, the question about the prevState passed to the parameter of the setState() function has not been resolved. Developers know that when you declare a class-type component and inherit React.Component, you can change the state through setState internally and use prevState without this.state or declarer. What I am curious about is, whether it is possible to bring the first parameter inside the state of the code below to a precarious state?

class App extends React.Component {
  state = {
    count: 0,
  }

  setState((prevState) => ({...prevState, count: prevState.count + 1}));

  render() {
    return <div>{this.state.count}</div>
  }

}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!