Managing Consistent Favorited State Across Paginated Searches with React Query
I have the following scenario: I have a search page with filters that queries for a list of companies (based on filters).
This means I have a cache entry for a list of company results.
Now user can mark a single or multiple companies as "favorites". This means I have to update the cache for the current page, but previous pages (cache entries) that the user searched for might also contain the same company.
For example, a user can search and get a list of companies including Apple. Then do a different search and get Apple again, then mark it as favorite.
If the user now goes back to the previous search, he will get the result from the cache and Apple won't be marked as favorite anymore.
How would you suggest approaching this? I realize I can invalidate all searches when user marks something as favorite but this is very inefficient
0 Replies