From 2f12be405a728f5697295d35c077c49dcb046bae Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Mon, 18 Jul 2022 10:28:18 +0300 Subject: [PATCH] logo redirect to home fix --- src/components/layout/ApplicationBar.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/components/layout/ApplicationBar.js b/src/components/layout/ApplicationBar.js index 94481a7..bebc5ea 100644 --- a/src/components/layout/ApplicationBar.js +++ b/src/components/layout/ApplicationBar.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useState, useEffect, useMemo } from "react"; import { makeStyles } from "@material-ui/core/styles"; import { Container, @@ -75,23 +75,20 @@ const ApplicationBar = () => { setAnchorEl(null); }; - const getFlagsPath = () => { - const basePath = "/public/flags"; - if (process.env.PUBLIC_URL) { - return `${process.env.PUBLIC_URL}/${basePath}`; - } else { - return basePath; - } - }; + const routePrefix = useMemo(() => process.env.PUBLIC_URL ?? "", [ + process.env.PUBLIC_URL + ]); + + const flagsPath = useMemo(() => `${routePrefix}/public/flags`, [routePrefix]); return (
- + logo @@ -118,7 +115,7 @@ const ApplicationBar = () => { format="png" pngSize={32} shiny={true} - basePath={getFlagsPath()} + basePath={flagsPath} alt={flag.alt} /> )}