How to use the @reach/router.globalHistory.location function in @reach/router

To help you get started, we’ve selected a few @reach/router 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 iamskok / jamstack.systems / src / gatsby-theme-mdx-deck / components / deck.js View on Github external
const getIndex = () => {
  const { pathname } = globalHistory.location
  const paths = pathname.split('/')
  const n = Number(paths[paths.length - 1])
  const index = isNaN(n) ? 0 : n
  return index
}
github jxnblk / mdx-deck / packages / components / src / Style.js View on Github external
const isPrintPath = () => {
  const { pathname } = globalHistory.location
  const parts = pathname.split('/')
  const path = parts[parts.length - 1]
  return path === 'print'
}
github appbaseio / Docs / src / components / common / MobileLinks.js View on Github external
constructor(props) {
		super();
		const link = globalHistory && globalHistory.location && globalHistory.location.pathname;
		const { file } = props;
		const sidebarFile = getSidebarFile(file);
		const items = sidebarFile.groups
			? sidebarFile.groups
					.filter(item => !!item.items)
					.reduce((agg, item) => {
						const parsedItems = item.items.map(links => ({
							...links,
							topic: item.group,
						}));

						return [...parsedItems, ...agg];
					}, [])
			: sidebarFile.items;
		let group = null;
		if (link) {
github jxnblk / mdx-deck / packages / components / src / Presenter.js View on Github external
<div style="{{">
        <pre>          {index} of {slides.length - 1}
        </pre>
        <div style="{{">
        <a style="{{" href="{globalHistory.location.origin" rel="noopener noreferrer">
          Open New Window
        </a>
        <div style="{{">
        
      </div>
    </div>
  )
}
</div>
github pomber / code-surfer / packs / code-surfer / src / presenter.tsx View on Github external
alignItems: "center",
            justifyContent: "space-between",
            width: "100%",
            padding: "0 16px",
            background: "#333"
          }}
        &gt;
          <pre>            Slide {index + 1} of {slides.length}
          </pre>
          
        
        <a style="{{" href="{globalHistory.location.origin" rel="noopener noreferrer">
          Open Slides in New Window
        </a>
      
      <div style="{{">
        </div>
github appbaseio / Docs / src / components / common / MobileNav.js View on Github external
const getValue = () => {
	if (globalHistory) {
		const path = globalHistory.location && globalHistory.location.pathname;
		if (path && path.startsWith('/docs/reactivesearch/v2')) {
			return 'React - v2';
		}
		if (path && path.startsWith('/docs/reactivesearch/vue-searchbox')) {
			return 'Vue SearchBox';
		}
		if (path && path.startsWith('/docs/reactivesearch/vue')) {
			return 'Vue';
		}
		if (path && path.startsWith('/docs/reactivesearch/native')) {
			return 'Native';
		}
		if (path && path.startsWith('/docs/reactivesearch/searchbase')) {
			return 'SearchBase';
		}
		if (path && path.startsWith('/docs/reactivesearch/react-searchbox')) {
github jxnblk / mdx-deck / packages / gatsby-theme / src / components / presenter-footer.js View on Github external
export default props =&gt; {
  const context = useDeck()
  const { index, length } = context

  return (
    
      <div>
        {index} / {length - 1}
      </div>
      <div>
        <a rel="noopener noreferrer" href="{globalHistory.location.href}">
          Open in New Window ↗︎
        </a>
      </div>
      <div>
      <div></div></div>
github jxnblk / mdx-deck / packages / components / src / QueryString.js View on Github external
const getQuery = () => {
  const query = querystring.parse(
    globalHistory.location.search.replace(/^\?/, '')
  )
  return query
}
github jxnblk / mdx-deck / packages / components / src / QueryString.js View on Github external
useEffect(() => {
    const { pathname, search } = globalHistory.location
    if (mode !== modes.NORMAL && mode !== modes.PRINT) {
      const query = '?' + querystring.stringify({ mode })
      if (query === search) return
      navigate(query)
    } else {
      if (!search) return
      navigate(pathname)
    }
  }, [mode])