MCPcopy Create free account
hub / github.com/reactjs/react-modal / ReactRouterModal

Function ReactRouterModal

examples/basic/react-router/index.js:14–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12const shouldOpenModal = locationPath => /\bmodal\b/.test(locationPath);
13
14const ReactRouterModal = props => (
15 <Modal
16 isOpen={shouldOpenModal(props.location.pathname)}
17 onRequestClose={() => history.push("/basic")}>
18 <div>
19 <Link to="/basic/modal/a">Link A</Link><br />
20 <Link to="/basic/modal/b">Link B</Link>
21 <div>
22 <Switch location={props.location}>
23 <Route path="/basic/modal/a" component={Content('A')} />
24 <Route path="/basic/modal/b" component={Content('B')} />
25 </Switch>
26 </div>
27 </div>
28 </Modal>
29);
30
31class App extends Component {
32 render() {
33 return (
34 <Router history={history}>
35 <div>
36 <Link to="/basic/modal" className="btn btn-primary">Modal</Link>
37 <Route path="/basic/modal" component={ReactRouterModal} />
38 </div>
39 </Router>
40 );
41 }
42}
43
44export default {
45 label: "react-modal and react-router.",
46 app: App
47};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected