Using the outlet MatchDetails

    Note: All examples assume that the default HashHistory history manager is being used.

    • queryParams: { [index: string]: string }: The query params from the matched route.
    • given the URL path /#home?foo=bar&baz=42, the queryParams object will look like:
    1. {
    2. foo: 'bar',
    3. baz: '42'
    4. }

    params

    • params: { [index: string]: string }: The path params from the matched route.
    1. export default [
    2. {
    3. path: 'home/{page}',
    4. outlet: 'home'
    5. }
    6. ];
    • given the URL path /#home/about, the params object will have look like:
    • isExact(): boolean: A function that indicates if the outlet is an exact match for the path. This can be used to conditionally render different widgets or nodes.
    1. export default [
    2. {
    3. path: 'home',
    4. outlet: 'home',
    5. children: [
    6. {
    7. path: 'about',
    8. }
    9. }
    10. ];
    • given the above route definition, if the URL path is set to /#home/about, then isExact() will evaluate to false for the Outlet with the id “home” and true for the an Outlet that is a child of the home Outlet with the id “about” as shown in the following file:

    src/App.tsx

    1. import { create, tsx } from '@dojo/framework/core/vdom';
    2. import Outlet from '@dojo/framework/routing/Outlet';
    3. const factory = create();
    4. export default factory(function App() {
    5. return (
    6. <div>
    7. <Outlet
    8. id="home"
    9. renderer={(homeMatchDetails) => {
    10. console.log('home', homeMatchDetails.isExact()); // home false
    11. return (
    12. <Outlet
    13. id="about"
    14. renderer={(aboutMatchDetails) => {
    15. console.log('about', aboutMatchDetails.isExact()); // about true
    16. return [];
    17. }}
    18. />
    19. );
    20. }}
    21. />
    22. );
    23. });

    isError()

    • isError(): boolean: A function indicates if the outlet is an error match for the path. This indicates after this outlet was matched, no other matches were found.
    • given this route definition, if the URL path is set to /#home/foo then there is no exact route match, so the isError() method on the home ‘s martchDetails object will yield true. Navigating to /#home or /#home/about however will cause the same method to return false since both routes are defined.
    • type: 'index' | 'partial' | 'error': The type of match for the route, either index, partial or error. Using type should not be necessary, instead favouring a combination of isExact and isError.
    1. export default [
    2. {
    3. path: 'home',
    4. outlet: 'home',
    5. children: [
    6. path: 'about',
    7. outlet: 'about'
    8. ]
    9. }
    10. ];
    • given the above route definition, the following values of type would be provided to each outlet:

    router

    • router: RouterInterface: The router instance which can used to create links and initiate route changes. For more information see the router API.

    src/routes.ts

    1. export default [
    2. {
    3. path: 'home',
    4. outlet: 'home',
    5. children: [
    6. {
    7. path: 'details',
    8. outlet: 'home-details'
    9. }
    10. ]