How to use the boring-router.RouteMatch.segment function in boring-router

To help you get started, we’ve selected a few boring-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 makeflow / boring-router / packages / boring-router-react / examples / segment / main.tsx View on Github external
import {BrowserHistory, Link, Route} from '../../bld/library';

const history = new BrowserHistory();

const router = new Router(history);

const route = router.$route({
  default: {
    $match: '',
  },
  account: {
    $exact: true,
    $children: {
      id: {
        $match: RouteMatch.segment,
      },
    },
  },
});

@observer
export class App extends Component {
  render(): ReactNode {
    return (
      <>
        <h1>Boring Router</h1>
        
          <p>Home page</p>
          <div>
            
              Account 123</div>
github makeflow / boring-router / packages / boring-router-react / examples / service / main.tsx View on Github external
get avatarURL(): string {
    return `https://gravatar.com/avatar/${this.id}`;
  }
}

const router = new Router(history);

const route = router.$route({
  default: {
    $match: '',
  },
  account: {
    $children: {
      id: {
        $match: RouteMatch.segment,
        $extension: {
          tick: undefined! as number,
          account: undefined! as Account,
        },
      },
    },
  },
  profile: true,
  notFound: {
    $match: RouteMatch.rest,
  },
});

type AccountIdRouteMatch = typeof route.account.id;

class AccountIdRouteService implements IRouteService {

boring-router

A type-safe MobX router with parallel routing support.

MIT
Latest version published 7 months ago

Package Health Score

59 / 100
Full package analysis

Similar packages