Lets consider this to be the component:
<code>const Alert = () => {
useEffect(() => {
alert("hello");
}, []);
return <div>Alert</div>;
};
</code>
<code>const Alert = () => {
useEffect(() => {
alert("hello");
}, []);
return <div>Alert</div>;
};
</code>
const Alert = () => {
useEffect(() => {
alert("hello");
}, []);
return <div>Alert</div>;
};
It is being understood that useEffect
runs after the browser has been painted.
But in this code, why does alert pops up before the browser is painted completely?
NOTE: if it is not happening at the first time, try refreshing it.