Feliz
Feliz copied to clipboard
React.useDeferred doesn't works with HMR
Because of the usage of React.useCancellationToken()
when an HMR call has been triggered the async call is never triggered again.
https://github.com/Zaid-Ajaj/Feliz/blob/52907b11f64c758282f2986f1aed0c91d46481b0/Feliz.UseDeferred/UseDeferred.fs#L62-L81
Hi there @MangelMaxime,
Any chance you had a look at this issue to figure out what is wrong exactly with React.useCancellationToken()
?
I need to check again because I don't remember exactly.
But if I remember correctly the problem was that the token was marked as cancelled and never recreated/refreshed.
Workflow:
- App is loaded
- Component can fetch data from the server
- HMR happen which cause the
token
to be marked as cancelled - Component try to fetch data again but failed because the
token
is marked as cancelled
Do you think we need to pass a dependencies array to the cancelation token hook?
I think I tried that and it didn't work any better. So in my code I disabled the cancellation support when compiling for DEBUG.
This need to be re-visited to see if I did something wrong at the time or not.