this code:
const TooMany = () => {
const [count, setCount] = useState(0);
const foo = (param) => {
console.log("Called twice")
return param;
}
let bar = foo(1);
return (
<div>
TEST
</div>
)
}
runs foo
twice. Why? My guess was that the second one is triggered by useState
but when I created another useState
it did not increase amount of the foo
calls. So I am confused...