Replies: 1 comment
-
+1 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I work on stock chart widgets where I use two kinds of requests:
To fetch data and display charts I use 3
useQuery
instances:initialQuery
refetchInterval
option) //updatesQuery
queryFn
to store full stock data initialized byinitialQuery
data and appended by periodical updates fromupdatesQuery
//fullQuery
(btw, latest documentation saysqueryFn
is required (if no default query function has been defined), but it seems addingenabled: false
also makes it optional)When a new component is mounted,
fullQuery
data is used to display initial graph. When new updates are coming (updatesQuery
), I add them to existing graph (without re-rendering the initial points).If I add more components for the same stock, they don't need data from
updatesQuery
asfullQuery
already contains all points. So for new components I need to discard the existing updates (updatesQuery.data
).Currently I do this by checking time of component first render and
updatesQuery.dataUpdatedAt
:Ideally, it would be nice to have an option like
discardDataOnMount
that would allow to do the same without manual checks:It could be useful for scenarios with multiple components displaying data from same source (stock data, chats with new messages, something else) and periodical polling.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions