router icon indicating copy to clipboard operation
router copied to clipboard

Exposing a way to delete all match cache

Open Angelelz opened this issue 3 years ago • 3 comments

Context: #250

First of all, this is one of my first times I've ever contributed code to a project like this, I'm a WIP developer very much in a beginner level, so please excuse me if this is a trivial or wrong thing to work on, or if I didn't do it right. It's just 3 lines of code that would help the project I'm working on right now.

Usage:

const router = useRouter();

if (!isLoggedIn) {
  router.removeAllCache();
}

Or:

const router = useRouter();

const loagoutHandler = (event: React.MouseEvent<HTMLButtonElement>) => {
  event.preventDefault();
  authCtx.logout();
  router.removeAllCache();
}

Or something similar.

Thanks.

Angelelz avatar Mar 27 '22 20:03 Angelelz

@Angelelz is attempting to deploy a commit to the Tanstack Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Mar 27 '22 20:03 vercel[bot]

Is this something the Author is not interested in? Any thoughts or comment? Is there any plan to implement any other way to destroy the preloaded data? Thanks,

Angelelz avatar Sep 17 '22 15:09 Angelelz

Next version will have this as a first class api.

tannerlinsley avatar Sep 17 '22 16:09 tannerlinsley

TanStack Router now has router.clearMatchCache()

tannerlinsley avatar Nov 10 '22 15:11 tannerlinsley