<Route/>

Description

<Route/> component is an only child component that <Switch/> can take.

<Route/> itself does not do anything special inside. This is used to provide the common interface for <Switch/>.

Basic Usage

<Route/> has to be used as a direct child of <Switch/> component.

RouteExample.jsx
import React from 'react'
import {Switch, Route} from 'react-queue-router'

import Top from './Top'
import About from './About'
import NotFound from './NotFound'

const RouteExample = () => {
  return (
    <Switch>
      <Route path='/' component='Top'>
      <Route path='/about' component='About'>
      <Route component='NotFound'>
    </Switch>
  )
 }
 
export default RouteExample

Options

PropertyType of valueDefault valueRequiredDescription
pathString-requiredComponent will be mounted when the given path matches the currentPath. If path is not set, the route always matches. Matching is implemented from top to bottom, and only one route can match at a time.
componentReact Component-requiredFeed a component you want to show.
exactBooleantrue-When true, the given path will match the end of the string of currentPath.
See the route match pattern below.
strictBooleanfalse-When true with the combination of exact, it enforces strict matching of trailing slashes.
See the route match pattern below.
sensitiveBooleanfalse-When true, matching will be case sensitive.

About currentPath, see RouterContext page.

Route match pattern

pathlocation.pathnameexactstrictMatches?
/one/two/one/two/falsefalse
/one/two/one/two/truefalse
/one/two/one/two/falsetrue
/one/two/one/two/truetrue
/one/two//one/twofalsefalse
/one/two//one/twotruefalse
/one/two//one/twofalsetrue
/one/two//one/twotruetrue

Handle 404 page

As you see in Basic Usage example, you can handle 404 page by giving a <Route/> component without path.

Since the <Route/> component without path matches any currentPath, you need to place it at the last.