I tried to do something like this using React Navigation where
useFocusEffect(useCallback(() => {
return () => saveFormAsync(formData)
}, []));
saveFormAsync
is an async
method returning a Promise<void>
.
It seems to work, but I am not sure if I am handling all the cases.
I noted React 16 as React 17 calls cleanup functions asynchronously