react useContext inside useEffect code example
Example 1: useeffect umnount
useEffect(() => {
return () => {
console.log("cleaned up");
};
}, []);
Example 2: useeffect
function App() {
const [count, setCount] = useState(0);
useEffect(() => {
longResolve().then(() => {
alert(count);
});
}, []);
return (
<div>
<button
onClick={() => {
setCount(count + 1);
}}
>
Count: {count}
</button>
</div>
);
}