DEV Community

Discussion on: Cancel your promises when a component unmounts

Collapse
 
rodw1995 profile image
Robbie

Hi Richard, I'm not sure what you mean. What I do in this example is the same as fetching the user in a useEffect hook:

useDidMount is just a custom hook that uses the useEffect hook. And because it uses the useEffect hook with no dependencies it can ensure that the callback is only executed ones i.e. after mount.

So, also in this example you would probably handle the mount case with a conditional for your component rendering.

Collapse
 
pencillr profile image
Richard Lenkovits

Ah, I see, then I just misunderstood useDidMount, thanks for the answer!