Skip to content

Commit

Permalink
don't update faviconUrl each render, lol
Browse files Browse the repository at this point in the history
  • Loading branch information
asktree committed Oct 2, 2023
1 parent 32aa4b1 commit af18079
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@ export function AppContents(props: Props) {
// Note: ?v==${Date.now()} is added to the url to force favicon refresh.
// Without it browsers would cache the last used and won't change it for different realms
// https://stackoverflow.com/questions/2208933/how-do-i-force-a-favicon-refresh
const faviconUrl =
symbol &&
tryParsePublicKey(symbol as string) === undefined && // don't try to use a custom favicon if this is a pubkey-based url
`/realms/${getResourcePathPart(
symbol as string
)}/favicon.ico?v=${Date.now()}`
const faviconUrl = useMemo(
() =>
symbol &&
tryParsePublicKey(symbol as string) === undefined && // don't try to use a custom favicon if this is a pubkey-based url
`/realms/${getResourcePathPart(
symbol as string
)}/favicon.ico?v=${Date.now()}`,
[symbol]
)

// check if a file actually exists at faviconUrl
const { result: faviconExists } = useAsync(
Expand Down

0 comments on commit af18079

Please sign in to comment.