Why the log still trigger although I didn't do setTest to change the test value? I expect for the first time the log should not trigger because the test value remain 0?
function App() {
const [test, setTest ] = useState(0)
useEffect(() => {
console.log('log')
}, [test])
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
</div>
);
}
I have a scenario like this. on first load don't do anything, then if user select an option on the page then do something, how do I do that with useEffect?