Why doesn't this async TanStack (React) Query function run unless I hit reload or re-expose the page? #7004
-
Hello. I'm a React and JavaScript newbie. I'm looking at the code below, and am at a loss to explain why "barney 0.5" is only logged on page reload or page re-expose, while barney 0.2 is logged every time as expected. BTW, it looks like none of e, al and iv are from useState. They're apparently just simple booleans. I've googled and googled, but nothing. And I asked on Stackoverflow, and got a response saying it's "dependent on how the query fn is being executed" Anyone? BTW, I'm using: A side question: If the enabled property is an evaluated-once-boolean expression (as it looks) and not a function that returns a boolean, how does react know to re-evaluate the expression for the retry counter? TIA!
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It turned out the queryKey was too inspecific, which was causing the data to be pulled from cache - even for pages that hadn't yet been pulled from the API. |
Beta Was this translation helpful? Give feedback.
It turned out the queryKey was too inspecific, which was causing the data to be pulled from cache - even for pages that hadn't yet been pulled from the API.