1
1
mirror of https://github.com/primer/css.git synced 2024-11-28 04:43:05 +03:00
css/docs/RouteMatch.js
2019-04-02 22:59:01 -07:00

18 lines
513 B
JavaScript

import React from 'react'
import {addPath} from './utils'
/**
* <RouteMatch> is just a way to conditionally render content without a wrapper
* element when contained directly in a <Router>:
*
* ```jsx
* <Router>
* <RouteMatch path="/some/dir">
* this will only show up on pages whose path begins with "/some/dir"
* </RouteMatch>
* </Router>
* ```
*/
export default function RouteMatch({path, children}) {
return path ? React.Children.map(children, child => addPath(child, path)) : children
}