You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
providing initialValue to useAsync blocks subsequent requests. this is unexpected behavior when server side rendering, where initialValue is provided to hydrate the client, but subsequent requests should fetch new information
Expectation
when start() is called due to watch, watchFn, or reload(), initialValue is ignored and the fetch is re-run with the new arguments
the only two places where counter.current++ is called are in cancel() and start() (where it is never reachable). calling cancel() (while a request is not inflight) increments counter and allows subsequent requests to proceed as expected
The text was updated successfully, but these errors were encountered:
shrugs
changed the title
initialValue is always re-used for subsequent fetches, regardless of
initialValue is always re-used for subsequent fetches if provided
Jan 23, 2020
Context
providing
initialValue
touseAsync
blocks subsequent requests. this is unexpected behavior when server side rendering, whereinitialValue
is provided to hydrate the client, but subsequent requests should fetch new informationExpectation
when
start()
is called due towatch
,watchFn
, orreload()
,initialValue
is ignored and the fetch is re-run with the new argumentsActual
because no requests have actually be fired, counter.current is always 0 and there are no last args, meaning
load
is always called for subsequent refetches and early exits due to https://github.com/async-library/react-async/blob/next/packages/react-async/src/useAsync.tsx#L156Workaround
the only two places where
counter.current++
is called are incancel()
andstart()
(where it is never reachable). callingcancel()
(while a request is not inflight) increments counter and allows subsequent requests to proceed as expectedThe text was updated successfully, but these errors were encountered: