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 am fetching an array of posts using SWR in a React native app and then displaying the data using React Native's flatlist.
When a user click's a like button on an item a function is called and the data is mutated on the server and the cache is updated to reflect the updated data.
The issue is when the data is mutated and revalidated it causes the flat list to re-render and the images to flash.
I have tried using useCallback to wrap the function and React.memo to wrap the renderItem, but neither are fixing the issue.
I've also made the keyExtractor a random number, to make sure each item is receiving a unique value.
How can I avoid this happening using SWR? Should I set revalidate:false?
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
Uh oh!
There was an error while loading. Please reload this page.
-
I am fetching an array of posts using SWR in a React native app and then displaying the data using React Native's flatlist.
When a user click's a like button on an item a function is called and the data is mutated on the server and the cache is updated to reflect the updated data.
The issue is when the data is mutated and revalidated it causes the flat list to re-render and the images to flash.
I have tried using useCallback to wrap the function and React.memo to wrap the renderItem, but neither are fixing the issue.
I've also made the keyExtractor a random number, to make sure each item is receiving a unique value.
How can I avoid this happening using SWR? Should I set revalidate:false?
Here is my code:
Beta Was this translation helpful? Give feedback.
All reactions