No function for incrementing?


this part:

  handleClick() {
      counter: this.state.counter + 1 // change code here

Isn’t this supposed to be a function for result based on previous value?

  handleClick() {
    this.setState(state => ({

or is there a reason it’s not necessary?

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36

Challenge: Render Conditionally from Props

Link to the challenge:

1 Like

you can set the state to whatever you want; even a boolean. setState(true) would be allowed. You don’t need the updater argument

Typescript may stop from setting any value you want but that’s kind of getting ahead

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.