const React = require('react'); const PropTypes = require('prop-types'); const classnames = require('classnames'); const UrlUtils = require('url'); const Icon = require('stremio-icons/dom'); const { Input } = require('stremio-navigation'); const useLocationHash = require('../../useLocationHash'); const styles = require('./styles'); const NavBarButton = React.memo(({ className, icon, label, href, onClick }) => { const locationHash = useLocationHash(); const active = React.useMemo(() => { 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 (
{label}
); }); NavBarButton.displayName = 'NavBarButton'; NavBarButton.propTypes = { className: PropTypes.string, icon: PropTypes.string, label: PropTypes.string, href: PropTypes.string, onClick: PropTypes.func }; module.exports = NavBarButton;