How i can do memory cleaning by cat.destroy() method when component is dead?
const object = useMemo(() => {
return new Cat()
}, [])
How i can do memory cleaning by cat.destroy() method when component is dead?
const object = useMemo(() => {
return new Cat()
}, [])
clean up effects for hooks you execute when a component will be unmounted. It's performed by a returned function at your useEffect hook:
useEffect(() => {
// return a function to be executed at component unmount
return () => object.destroy()
}, [object])