How to use the @reach/router.createMemorySource 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 reach / reach-ui / packages / menu-button / examples / with-links.example.js View on Github external
MenuItem
} from "@reach/menu-button";
import {
  Router,
  Link,
  createMemorySource,
  createHistory,
  LocationProvider
} from "@reach/router";
import "@reach/menu-button/styles.css";

export let name = "With Links";

// this is because we're in an iframe and not a
// pushState server inside of storybook
let memoryHistory = createHistory(createMemorySource("/"));

export function Example() {
  return (
    
      
        
        
      
    
  );
}

function Home() {
  return (
    <div>
      <h2>Home</h2></div>
github textileio / desktop / src / Stores / index.ts View on Github external
import { createMemorySource, createHistory } from '@reach/router'
import moment, { utc } from 'moment'
const { remote } = window.require('electron')
import path from 'path'
import URL from 'url-parse'

const DEFAULT_AVATAR = 'https://react.semantic-ui.com/images/wireframe/square-image.png'

export interface Message {
  name: string
  payload?: any
}

export type Screen = 'starting' | 'loading' | 'online' | 'error' | 'onboard' | 'landing'

const source = createMemorySource('/')
const history = createHistory(source)

// tslint:disable-next-line:no-empty-interface
export interface Store {}

export interface ProfileInfo {
  name: string
  avatar: string
  date: string
  address: string
}

export interface AppInfo {
  appId: string
  appName: string
  link: string
github gatsbyjs / gatsby / packages / gatsby-link / src / __tests__ / index.js View on Github external
it(`does not fail with missing __BASE_PATH__`, () =&gt; {
    global.__PATH_PREFIX__ = ``
    global.__BASE_PATH__ = undefined

    const source = createMemorySource(`/active`)

    expect(() =&gt;
      render(
        
          
            link
          
        
      )
    ).not.toThrow()
github microsoft / entref-spring-boot / ui / src / __tests__ / DefaultComponent.tsx View on Github external
test('It finds the page if user tries a nonsense path', () =&gt; {
            const badPath = '/awefwaef'
            const source = createMemorySource(badPath)
            const hist = createHistory(source)
            const r = render(
                
                    
                ,
                )

            expect(r.find('.default-component')).toHaveLength(1)
            expect(r.find('.default-component1')).toHaveLength(0)
        })
github microsoft / entref-spring-boot / ui / src / __tests__ / DefaultComponent.tsx View on Github external
test('It doesn\'t find the page if user tries a valid path', () =&gt; {
            const goodPath = '/titles'
            const source = createMemorySource(goodPath)
            const hist = createHistory(source)
            const r = render(
                
                    
                ,
                )

            expect(r.find('.default-component')).toHaveLength(0)
            })
        })
github gatsbyjs / gatsby / packages / gatsby-link / src / __tests__ / index.js View on Github external
const setup = ({ sourcePath = `/active`, linkProps, pathPrefix = `` } = {}) =&gt; {
  global.__BASE_PATH__ = pathPrefix
  const source = createMemorySource(sourcePath)
  const history = createHistory(source)

  const utils = render(
    
      
        link
      
    
  )
github topheman / react-fiber-experiments / src / testUtils.js View on Github external
const renderWithRouter = (ui, renderOptions = {}, { pathname = "/" } = {}) =&gt; {
  const history = createHistory(createMemorySource(pathname));
  return render(
    {ui},
    renderOptions
  );
};
github serrexlabs / pusthaka / src / Router.tsx View on Github external
import React from "react";
import { Router, createMemorySource, createHistory, LocationProvider } from "@reach/router";
import App from "./App";
import HomePage from "./pages/home-page";
import CollectionPage from "./pages/collection-page";

const source = createMemorySource("home");
const history = createHistory(source);

function MainRouter(): JSX.Element {
  return (
    
      
        
          
          
        
      
    
  );
}

export default MainRouter;