Consider the code snippet below:
import { useEffect } from "react";
export const Hello = () => {
useEffect(() => {
console.log("Mounted");
return () => {
console.log("Unmounted");
};
}, []);
return <h1>Hello</h1>;
};
I'm observing that every time I make some changes and save, I get the Unmounted
and Mounted
log printed, which means that the component is getting unmounted and then mounted back.
This is not something critical, but in my project I'm working with Iframes and on unmount I run some code that I don't want to run unnecessarily.
Was this the case from the start, did something change?