You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently even if we give fallback data using fallbackData option, the initial data for comparison (as proven by logging the a, b inside compare(a, b)) would still be undefined. Because of this, despite providing some sort of initial data, the first fetch would still set a new data object replacing it. Even if the new data and the initial data are exactly the same.
It would be great to have an option that treats fallbackData as the initial data (like the now-defunct initialData option). This way, even in the first fetch, the fetched data is deep-compared to the fallback data, not to undefined, and if they are exactly the same, a replacement of the data object should not happen. (This would be useful for preventing re-renders based on object pointer/address change without data change, which I believe is the point of using SWR with deep comparison in the first place.)
There are so many issues and discussions asking for this alternative behavior in one way or another:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently even if we give fallback data using
fallbackData
option, the initial data for comparison (as proven by logging thea, b
insidecompare(a, b)
) would still beundefined
. Because of this, despite providing some sort of initial data, the first fetch would still set a new data object replacing it. Even if the new data and the initial data are exactly the same.It would be great to have an option that treats
fallbackData
as the initial data (like the now-defunctinitialData
option). This way, even in the first fetch, the fetched data is deep-compared to the fallback data, not toundefined
, and if they are exactly the same, a replacement of the data object should not happen. (This would be useful for preventing re-renders based on object pointer/address change without data change, which I believe is the point of using SWR with deep comparison in the first place.)There are so many issues and discussions asking for this alternative behavior in one way or another:
fallbackData
in suspense mode #2436But no resolution yet. 🙁
To developers using SWR: If you think this will be useful, please vote Yes 🙂
1 vote ·
Beta Was this translation helpful? Give feedback.
All reactions