the course link is thishttps://www.codecademy.com/courses/react-101/lessons/the-state-hook/exercises/set-from-previous-state
I am not sure about one word of the following code:
import React, { useState } from 'react';
export default function Counter() {
const [count, setCount] = useState(0);
const increment = () => setCount(prevCount => prevCount + 1);
return (
<div>
<p>Wow, you've clicked that button: {count} times</p>
<button onClick={increment}>Click here!</button>
</div>
);
}
when we define the increasement, why do we use prevCount instead of count, compared with setCount, count is the previous one, meanwhile, we does not define what prevCount is.