8000 Replace the cache.modify deletion example with cache.evict · nirus/fullstack-tutorial@022f617 · GitHub
[go: up one dir, main page]

Skip to content

Commit 022f617

Browse files
committed
Replace the cache.modify deletion example with cache.evict
This shows how `cache.evict()` works, and we're alreay showing how `cache.modify()` works in another part of the application. Also, using `evict` in this case is much more succinct.
1 parent 121755b commit 022f617

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

final/client/src/containers/logout-button.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,12 @@ const LogoutButton = () => {
1313
data-testid="logout-button"
1414
onClick={() => {
1515
// Since we're logging out, remove all traces of the current user
16-
// from the cache. First use `cache.modify()` to remove the stored
16+
// from the cache. First use `cache.evict()` to remove the stored
1717
// `me` reference that was added to the cache by the `GET_MY_TRIPS`
1818
// query in `profile.tsx`. Then trigger garbage collection using
1919
// `cache.gc()` to remove the cached `User` object that is no longer
2020
// reachable.
21-
client.cache.modify(
22-
'ROOT_QUERY',
23-
{
24-
me(_, { DELETE }) {
25-
return DELETE;
26-
}
27-
}
28-
);
21+
client.cache.evict('ROOT_QUERY', 'me');
2922
client.cache.gc();
3023

3124
// Remove user details from localStorage.

0 commit comments

Comments
 (0)
0