This is the answer to one of my react course's problem.
import React from 'react';
const useState = React.useState;
export default function App() {
const [count, setCount] = useState(0);
const onButtonClick = () => {
setCount(count+1);
};
return (
<div>
<button onClick={onButtonClick}>Click Me!</button>
<h1>Current Count: {count}</h1>
</div>
);
}
In react, why does it cause error when you do put argument in onButtonClick function.
const onButtonClick = (count) => {
setCount(count+1);
};
Shouldn't we need to put count as argument in order to use it into function? What am I getting wrong?