how is 10 passed to increment counter num?
I wish to know better how that parameter is passed because I can't see it very clearly
const Button = React.memo(function Button({ incrementButton }) {
return <button onClick={() => incrementButton(10)}>+</button>;
});
Button.propTypes = {
incrementButton: P.func,
};
function App() {
const [counter, setCounter] = useState(0);
const incrementCounter = useCallback((num) => {
setCounter((c) => c + num);
}, []);
const btn = useMemo(() => {
return <Button incrementButton={incrementCounter} />;
}, [incrementCounter])
return (
<div className="App">
<p>Teste</p>
<h1>C1: {counter}</h1>
{btn}
</div>
);
}