-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Discussed in #5537
Originally posted by dev-rish June 5, 2023
Describe the Bug
After switching between 1 & 2 for couple of times (so that react query caches data for each of them), the useEffect still triggers twice.
The expected behavior is seen till v3.8.3 i.e. useEffect only triggers once. Once react query is updated to v3.9.0 every click on 1 or 2 causes useEffect to trigger twice.
Is there a way to prevent the second trigger?
I found related issues but still wanted some more info. if possible.
Minimal, reproducible example
v3: https://codesandbox.io/s/optimistic-firefly-1tk7i5
v4: https://codesandbox.io/s/sad-scott-cidk6s?file=/src/App.js
Steps to reproduce
Click in 1 > Click on 2 > Click in 1 > Click on 2
Expected behavior
useEffect to trigger only once when id is switched.
How often does this bug happen?
Always
Note:
- Seems to be
selectrelated, because it works as expected ifselectis removed - This is not strict mode related