the returned function fires on component Re-render also. How to you check if its an unmount or just a re-render ?
Basically its just a clean up function which runs every time the useEffect is used (except the first time)
As a software engineer with 3+ years of experience in NodeJS, React, PostgreSQL, and MongoDB. I have a can-do attitude and enjoy taking on new challenges. I take ownership of my work. I'm a quick lear
Are you sure? AFAIK it should not be the case, it's only triggered once the component is unmounting or remounting itself. So maybe you can check that out.
Also you might have other useEffect who are defined sooner and as you might know the order of defining useEffect hooks matter
the returned function fires on component Re-render also. How to you check if its an unmount or just a re-render ?
Basically its just a clean up function which runs every time the useEffect is used (except the first time)
Are you sure? AFAIK it should not be the case, it's only triggered once the component is unmounting or remounting itself. So maybe you can check that out.
Also you might have other useEffect who are defined sooner and as you might know the order of defining useEffect hooks matter
I suppose you could use a useRef to track the render (it will not be cleaned on a rerender). Depends on what you need it to do.