Użyj Effect umnount
useEffect(() => {
return () => {
console.log("cleaned up");
};
}, []);
Dark Dotterel
useEffect(() => {
return () => {
console.log("cleaned up");
};
}, []);