Skip to content
Source
Sign inSign up
TanStack/query

select runs twice #3095

Send to my agent
ClosedTkDodo opened this issue 2 comments
TkDodocommented

Describe the bug

a memoized select function runs twice under some circumstances, even though it should only run once.

circumstances:

  • query key stays the same
  • but select becomes a new value

Your Example Website or App

https://codesandbox.io/s/select-runs-twice-bf3pp

Steps to reproduce

  1. click the button
  2. observe the console.log - it should only execute select once.

Expected behavior

select should only be executed once per input

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

all

Additional context

if the query key changes with the input, select is correctly only executed once.

in this sandbox, I've only added input to the query key and things work:

https://codesandbox.io/s/select-runs-twice-forked-qrtqm?file=/src/App.tsx

  1. TkDodo added labelsbug

  2. TkDodo closed this

  3. :tada: This issue has been resolved in version 3.34.4 :tada:

    The release is available on:

    Your semantic-release bot :package::rocket:

  4. tannerlinsley added labelsreleased

  5. :tada: This issue has been resolved in version 4.0.0-alpha.5 :tada:

    The release is available on:

    Your semantic-release bot :package::rocket:

  6. tannerlinsley added labelsreleased on @alpha

Sign in to join this conversation.