From 8c10a467be38b267415ca0a36219688c65ea9f27 Mon Sep 17 00:00:00 2001
From: enes
Date: Thu, 16 Jan 2025 12:57:13 +0100
Subject: [PATCH] fix(router): revalited loaders on auth
---
src/layout/header.tsx | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/layout/header.tsx b/src/layout/header.tsx
index 1871374..8b6b454 100644
--- a/src/layout/header.tsx
+++ b/src/layout/header.tsx
@@ -3,7 +3,7 @@ import {
launch as launchNostrLoginDialog
} from 'nostr-login'
import React, { useEffect, useState } from 'react'
-import { Link } from 'react-router-dom'
+import { Link, useRevalidator } from 'react-router-dom'
import { Banner } from '../components/Banner'
import { ZapPopUp } from '../components/Zap'
import {
@@ -27,7 +27,7 @@ export const Header = () => {
const dispatch = useAppDispatch()
const { findMetadata } = useNDKContext()
const userState = useAppSelector((state) => state.user)
-
+ const revalidator = useRevalidator()
// Track nostr-login extension modal open state
const [isOpen, setIsOpen] = useState(false)
const handleOpen = () => setIsOpen(true)
@@ -75,8 +75,12 @@ export const Header = () => {
}
})
}
+
+ // React router - revalidate loader states on auth changes
+ revalidator.revalidate()
}
})
+ // eslint-disable-next-line react-hooks/exhaustive-deps
}, [dispatch, findMetadata])
const handleLogin = () => {
@@ -447,7 +451,9 @@ const RegisterButtonWithDialog = () => {
color: '#ffffffbf'
}}
>
- Warning: Make sure you backup your private key somewhere safe. If you lose it or it gets leaked, we actually can't help you.
+ Warning: Make sure you backup your private key
+ somewhere safe. If you lose it or it gets leaked, we
+ actually can't help you.