mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-08-16 03:17:07 +00:00
NavBarButton active memo refactored
This commit is contained in:
parent
092a09fe36
commit
7a2155c271
1 changed files with 6 additions and 4 deletions
|
|
@ -10,10 +10,12 @@ const styles = require('./styles');
|
|||
const NavBarButton = React.memo(({ className, icon, label, href, onClick }) => {
|
||||
const locationHash = useLocationHash();
|
||||
const active = React.useMemo(() => {
|
||||
const locationHashPath = locationHash.startsWith('#') ? locationHash.slice(1) : '';
|
||||
const hrefHashPath = typeof href === 'string' && href.startsWith('#') ? href.slice(1) : '';
|
||||
const { pathname: locationPathname } = UrlUtils.parse(locationHashPath);
|
||||
const { pathname: hrefPathname } = UrlUtils.parse(hrefHashPath);
|
||||
if (typeof href !== 'string') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { pathname: locationPathname } = UrlUtils.parse(locationHash.slice(1));
|
||||
const { pathname: hrefPathname } = UrlUtils.parse(href.slice(1));
|
||||
return locationPathname === hrefPathname;
|
||||
}, [href, locationHash]);
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in a new issue