T
TanStack2y ago
sunny-green

How to reload page?

Hey guys, can you help me with how to refresh the page? In React Router, I could use navigate(0), but how do I do it here? Or should I go with window.location.reload? Though, I'm not sure if that's the best option)
3 Replies
sunny-green
sunny-greenOP2y ago
"I found this method, but not sure if it's the right one:
const router = useRouter();
router.history.go(0);
const router = useRouter();
router.history.go(0);
Is this the correct way to refresh the page?
genetic-orange
genetic-orange2y ago
const router = useRouter()
router.invalidate()
const router = useRouter()
router.invalidate()
This invalidates all loaders and refreshes the page. If you actually want a full refresh (=F5): window.location.reload()
sunny-green
sunny-greenOP2y ago
Okay, thank you

Did you find this page helpful?