I'm not sure if what I am asking fits into that question exactly. I guess I'm wondering if in the hooks world there is the explicit unmounting that the abort could be called in. It seems a bit odd that useEffect implicitly mimicks the unmount and would only then execute the callback function.
This is likely a knowledge gap in my React, but I was hoping you might be able to provide a clearer take on it.
You supply a callback to the useEffect hook and this callback can return another callback.
The first callback is called on a mount event, the returned callback is the one that is called on an unmount event.
(If you supply an array as second argument to useEffect, the first callback is also executed if one of the elements intl this array changed between renders, if the array is empty, the first callback is only called in mount, like with my example)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You mean to give the user of the hook a way to call the abort manually?
I'm not sure if what I am asking fits into that question exactly. I guess I'm wondering if in the
hooks
world there is the explicit unmounting that the abort could be called in. It seems a bit odd thatuseEffect
implicitly mimicks the unmount and would only then execute the callback function.This is likely a knowledge gap in my React, but I was hoping you might be able to provide a clearer take on it.
Ah, okay.
You supply a callback to the useEffect hook and this callback can return another callback.
The first callback is called on a mount event, the returned callback is the one that is called on an unmount event.
(If you supply an array as second argument to useEffect, the first callback is also executed if one of the elements intl this array changed between renders, if the array is empty, the first callback is only called in mount, like with my example)