How to use inferno-router - 10 common examples

To help you get started, we’ve selected a few inferno-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 infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('creates a cache entry for each exact/strict pair', () => {
      // true/false and false/true will collide when adding booleans
      const trueFalse = matchPath('/one/two', {
        path: '/one/two/',
        exact: true,
        strict: false
      });
      const falseTrue = matchPath('/one/two', {
        path: '/one/two/',
        exact: false,
        strict: true
      });
      expect(!!trueFalse).toBe(true);
      expect(!!falseTrue).toBe(false);
    });
  });
github infernojs / inferno / packages / inferno-router / __tests__ / matchPath.spec.js View on Github external
it('creates a cache entry for each exact/strict pair', () => {
      // true/false and false/true will collide when adding booleans
      const trueFalse = matchPath('/one/two', {
        path: '/one/two/',
        exact: true,
        strict: false
      });
      const falseTrue = matchPath('/one/two', {
        path: '/one/two/',
        exact: false,
        strict: true
      });
      expect(!!trueFalse).toBe(true);
      expect(!!falseTrue).toBe(false);
    });
  });
github infernojs / inferno / packages / inferno-router / __tests__ / asyncBeforeBrowser.spec.jsx View on Github external
asyncBefore={url => {
            // console.log('Async before...')
            return doAllAsyncBefore(match(routes, url));
          }}
        >
github infernojs / inferno / packages / inferno-router / __tests__ / asyncBeforeBrowser.spec.jsx View on Github external
function didEnter() {
        requestAnimationFrame(() => {
          expect(innerHTML(container.innerHTML)).toBe(
            innerHTML("<div>Page No Async</div>")
          );
          done();
        });
      }

      const routes = (
        
          
        
      );

      const renderProps = match(routes, "/");
      doAllAsyncBefore(renderProps).then(() =&gt; {
        // Then render
        render(routes, container);
      });
    });
github infernojs / inferno / packages / inferno-router / __tests__ / asyncBeforeBrowser.spec.jsx View on Github external
const routes = (
        
          
        
      );

      // Need to prime the route props with data on first render. With SSR this should be done by hydration
      // so makes sense not to perform automagically in router.
      const renderProps = match(routes, "/");
      doAllAsyncBefore(renderProps).then(() =&gt; {
        // Then render
        render(routes, container);
      });
    });
github Paturages / chorus / src / app / components / organisms / NavBar / index.jsx View on Github external
&gt;
              gh3orus
            
            {/*  */}
            {/*
              TODO: Uncomment when feeling like implementing Discord auth
              
            */}
          
        
      
    );
  }
}

export default withRouter(NavBar);
github bs32g1038 / node-blog / blog / src / router-util / matchRoutes.js View on Github external
routes.some(route => {
    const match = route.path
      ? matchPath(pathname, route)
      : branch.length
        ? branch[branch.length - 1].match // use parent match
        : computeMatch(pathname); // use default "root" match

    if (match) {
      branch.push({ route, match });

      if (route.routes) {
        matchRoutes(route.routes, pathname, branch);
      }
    }

    return match;
  });
github bs32g1038 / node-blog / blog / src / router-util / matchRoutes.js View on Github external
import { Router, matchPath } from "inferno-router";

// ensure we're using the exact code for default root match
const { computeMatch } = Router.prototype;

const matchRoutes = (routes, pathname, /*not public API*/ branch = []) => {
  routes.some(route => {
    const match = route.path
      ? matchPath(pathname, route)
      : branch.length
        ? branch[branch.length - 1].match // use parent match
        : computeMatch(pathname); // use default "root" match

    if (match) {
      branch.push({ route, match });

      if (route.routes) {
        matchRoutes(route.routes, pathname, branch);
      }
    }
github infernojs / inferno / packages / inferno-router / __tests__ / withRouter.spec.jsx View on Github external
it('provides the parent match as a prop to the wrapped component', () =&gt; {
    let parentMatch;
    const PropsChecker = withRouter(props =&gt; {
      expect(props.match).toEqual(parentMatch);
      return null;
    });

    render(
      
         {
            parentMatch = match;
            return ;
          }}
        /&gt;
      ,
      node
    );
github infernojs / inferno / packages / inferno-router / __tests__ / withRouter.spec.jsx View on Github external
it('exposes the instance of the wrapped component via wrappedComponentRef', () =&gt; {
    class WrappedComponent extends Component {
      render() {
        return null;
      }
    }
    const TestComponent = withRouter(WrappedComponent);

    let ref;
    render(
      
          (ref = r)} /&gt;} /&gt;
      ,
      node
    );

    expect(ref instanceof Component).toBe(true);
  });

inferno-router

Provides routing functionality for Inferno

MIT
Latest version published 4 months ago

Package Health Score

79 / 100
Full package analysis