TanStackT
TanStack3y ago
7 replies
wispy-olive

Waiting for fresh data before displaying component

Hi! I'm creating forms that use the technique described in https://tkdodo.eu/blog/react-query-and-forms, where react-query is used to populate the initial data but then it's turned into local state for the form while it's being edited.

If there is stale data already cached, then during the component load I might accidentally use the stale data as the initial data. What's the recommended way to wait for fresh data before rendering the form? Currently I just want for query.data !== undefined but I was wondering if it might be enough to replace that with query.isFetching or something else. Thank you!
Was this page helpful?