grassrootsgrocery / admin-portal

GNU Affero General Public License v3.0
10 stars 5 forks source link

Use "invalidateQueries" instead of "refetch" #70

Closed jasoncavanaugh closed 11 months ago

jasoncavanaugh commented 1 year ago

Currently, after running a mutation on the frontend, we use react-query's refetch function to refetch the data that was mutated. (You can see an example of this in AssignLocationDropdown.tsx.) Instead of calling the refetch, we should use react-query's invalidateQueries to mark those queries as stale in the cache. This would mean that we don't need to pass the refetch function around as a prop, and we also would only make the refetch when necessary. See this issue for more information https://github.com/TanStack/query/discussions/2468

mattsahn commented 1 year ago

Hey, @jasoncavanaugh, this looks like a good practice to implement. Can you take this one on?

jasoncavanaugh commented 1 year ago

Yep, let me try to implement this tomorrow