How to use the react-use.useLocation function in react-use

To help you get started, we’ve selected a few react-use examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 0xTracker / 0x-tracker-client / src / features / header / components / sub-navigation-parent.js View on Github external
const timeout = setTimeout(() => {
      setOpen(false);
    }, 100);

    setBlurTimeout(timeout);
  });

  const activeHandler = useCallback(() => {
    // Clear the blur timeout to prevent sub-navigation from disappearing when
    // the user navigates between elements.
    clearTimeout(blurTimeout);

    setOpen(true);
  });

  const location = useLocation();
  const highlighted = items.some(item =>
    location.pathname.startsWith(item.href),
  );

  return (
    
      
        {children}
github 0xTracker / 0x-tracker-client / src / features / header / components / expandable-mobile-navigation-item.js View on Github external
const ExpandableMobileNavigationItem = ({ children, items, onNavigate }) => {
  const location = useLocation();
  const highlighted = items.some(item =>
    location.pathname.startsWith(item.href),
  );
  const [expanded, setExpanded] = React.useState(highlighted);
  const handleClick = () => setExpanded(!expanded);

  return (
    <>
      
        {children}
        {expanded ?  : }
      
      {expanded ? (
        
      ) : null}
github kyma-project / website / src / root / services / root.ts View on Github external
function useRootService() {
  const [language, setLanguage] = useState("en");
  const { pathname, hash } = useLocation();

  useEffect(() => {
    if (!window.__GATSBY_ROUTE_UPDATED) {
      setTimeout(() => {
        window.__GATSBY_ROUTE_UPDATED = true;
      }, 25);
    }
  }, [pathname, hash]);

  return {
    language,
    setLanguage,
  };
}
github EnixCoda / Gitako / src / components / SideBar.tsx View on Github external
function useOnLocationChange(callback: React.EffectCallback, extraDeps: React.DependencyList = []) {
  const { href, pathname, search } = useLocation()
  React.useEffect(callback, [href, pathname, search, ...extraDeps])
}
github 0xTracker / 0x-tracker-client / src / features / news / components / articles-filter.js View on Github external
const ArticlesFilter = ({ sources }) => {
  const location = useLocation();

  return (
    <nav>
      
        All
        
      
      {sources.map(source =&gt; {
        const sourceUrl = `${URL.NEWS}/${source.slug}`;

        return (
          </nav>
github 0xTracker / 0x-tracker-client / src / features / header / components / navigation-link.js View on Github external
const NavigationLink = ({ href, children }) =&gt; {
  const location = useLocation();
  const active = location.pathname.startsWith(href);

  return (
    
      {children}
    
  );
};
github 0xTracker / 0x-tracker-client / src / features / header / components / mobile-sub-navigation.js View on Github external
const MobileSubNavigation = ({ items, onNavigate }) =&gt; {
  const location = useLocation();

  return (
    
      {items.map(item =&gt; (
        
          {item.title}
        
      ))}
    
  );
};
github kyma-project / website / src / views / roadmap / Services / tickets.service.ts View on Github external
const TicketsService = () =&gt; {
  const {
    pageContext: { capabilities },
    scrollToTicketsReference,
  } = useRoadmapService();
  const location = useLocation();
  const [{ filters, initial }, setState] = useState(initialState);

  interface ReleaseWithNumber {
    release: Release;
    orderNumber: number;
  }

  const prepareReleases = (): ReleaseWithNumber[] =&gt;
    new TicketsProcessor(tickets as Tickets)
      .sortReleases()
      .filterCapabilitiesByQueryParams(filters, capabilities)
      .filterCapabilitiesWithoutCapabilities()
      .removeCapabilitiesWithoutTickets()
      .createReleasesWithNumber()
      .returnReleasesWithNumber();
github 0xTracker / 0x-tracker-client / src / features / header / components / sub-navigation-item.js View on Github external
const SubNavigationItem = ({ children, href }) =&gt; {
  const location = useLocation();
  const highlighted = location.pathname.startsWith(href);

  return (
    
      {children}
    
  );
};
github 0xTracker / 0x-tracker-client / src / features / header / components / mobile-navigation-link.js View on Github external
const MobileNavigationLink = ({ children, href, onClick }) =&gt; {
  const location = useLocation();
  const highlighted = location.pathname.startsWith(href);

  return (
    
      {children}
    
  );
};