1
import React, {useState} from 'react';
const [count,setCount] = useState(5);

const incrementcount = () => {
setCount(count+1);
}
return (
<div>
<button onClick={incrementcount}> + </button>
<span> {count} </span>
<button> - </button>
</div>
)
}

export default App;

when I use 'count++' instead of 'count+1',it shows an error...why so?

  • 4
    Does this answer your question? [How to use the increment operator in React](https://stackoverflow.com/questions/39316376/how-to-use-the-increment-operator-in-react) – Harmandeep Singh Kalsi Aug 09 '20 at 11:29

0 Answers0