(

Accounts

{/* It's possible to use regular expressions to control what param values should be matched. * "/order/asc" - matched * "/order/desc" - matched * "/order/foo" - not matched */}
); const Child = ({ match }) => (

ID: {match.params.id}

"> (

Accounts

{/* It's possible to use regular expressions to control what param values should be matched. * "/order/asc" - matched * "/order/desc" - matched * "/order/foo" - not matched */}
); const Child = ({ match }) => (

ID: {match.params.id}

"> (

Accounts

{/* It's possible to use regular expressions to control what param values should be matched. * "/order/asc" - matched * "/order/desc" - matched * "/order/foo" - not matched */}
); const Child = ({ match }) => (

ID: {match.params.id}

">
import React from "react";
import { BrowserRouter as Router, Route, Link } from "react-router-dom";

const ParamsExample = () => (
  <Router>
    <div>
      <h2>Accounts</h2>
      <ul>
        <li>
          <Link to="/netflix">Netflix</Link>
        </li>
        <li>
          <Link to="/zillow-group">Zillow Group</Link>
        </li>
        <li>
          <Link to="/yahoo">Yahoo</Link>
        </li>
        <li>
          <Link to="/modus-create">Modus Create</Link>
        </li>
      </ul>

      <Route path="/:id" component={Child} />

      {/*
         It's possible to use regular expressions to control what param values should be matched.
            * "/order/asc"  - matched
            * "/order/desc" - matched
            * "/order/foo"  - not matched
      */}
      <Route
        path="/order/:direction(asc|desc)"
        component={ComponentWithRegex}
      />
    </div>
  </Router>
);

const Child = ({ match }) => (
  <div>
    <h3>ID: {match.params.id}</h3>
  </div>
);

const ComponentWithRegex = ({ match }) => (
  <div>
    <h3>Only asc/desc are allowed: {match.params.direction}</h3>
  </div>
);

export default ParamsExample;
<Route
  path="/order/:direction(asc|desc)"
  component={ComponentWithRegex}
/>

위와 같은 식으로 설정을 하게되면 direction 값이 asc, desc 일 경우에만 해당 라우트를 타게 된다.

React Router: Declarative Routing for React