Zaid-Ajaj / Feliz

A fresh retake of the React API in Fable and a collection of high-quality components to build React applications in F#, optimized for happiness
https://zaid-ajaj.github.io/Feliz/
MIT License
534 stars 78 forks source link

React.useDeferred doesn't works with HMR #511

Open MangelMaxime opened 1 year ago

MangelMaxime commented 1 year ago

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

Zaid-Ajaj commented 1 year ago

Hi there @MangelMaxime,

Any chance you had a look at this issue to figure out what is wrong exactly with React.useCancellationToken()?

MangelMaxime commented 1 year ago

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:

  1. App is loaded
  2. Component can fetch data from the server
  3. HMR happen which cause the token to be marked as cancelled
  4. Component try to fetch data again but failed because the token is marked as cancelled
Zaid-Ajaj commented 1 year ago

Do you think we need to pass a dependencies array to the cancelation token hook?

MangelMaxime commented 1 year ago

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.