after I read this article When should I use a return statement in ES6 arrow functions, I'm still a little bit confused.Why the following code useEffect uses the curly braces, but without return it still works? Not sure if I misunderstand something.
Here is the example:
import React,{useEffect,useState} from "react"
function App() {
const [resourcetype,setresourcetype]=useState("posts")
useEffect(()=>{
console.log("render")
},[resourcetype])
return (
<div>
<button onClick={()=>setresourcetype("try")}>try</button>
<button onClick={()=>setresourcetype("unknown")}>unknown</button>
</div>
);
}
export default App;