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
I made changes to data returned from useSWR, to format the data. This updated the SWR cache with the formatted data, which later resulted in a different useSWR hook returning the formatted data, which is incorrect.
Expected Behavior
I would expect that any changes made to the data object be made locally only and not propagated to the SWR cache.
I don't think making changes directly to data is great practice anyway, but it can be fairly easy to do so accidentally. In my case I had mistakenly expected a lodash function to return a copy of the data and not the data object itself. While I understand why this would make changes to data locally, I was surprised to find this affected the cache as I would not expect changes outside of the fetcher function to make changes to the cache.
The text was updated successfully, but these errors were encountered:
Bug report
Description / Observed Behavior
I made changes to
data
returned from useSWR, to format the data. This updated the SWR cache with the formatted data, which later resulted in a different useSWR hook returning the formatted data, which is incorrect.Expected Behavior
I would expect that any changes made to the data object be made locally only and not propagated to the SWR cache.
Repro Steps / Code Example
CodeSandbox
Additional Context
I don't think making changes directly to
data
is great practice anyway, but it can be fairly easy to do so accidentally. In my case I had mistakenly expected a lodash function to return a copy of the data and not the data object itself. While I understand why this would make changes todata
locally, I was surprised to find this affected the cache as I would not expect changes outside of the fetcher function to make changes to the cache.The text was updated successfully, but these errors were encountered: