| 12 | const shouldOpenModal = locationPath => /\bmodal\b/.test(locationPath); |
| 13 | |
| 14 | const 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 | |
| 31 | class 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 | |
| 44 | export default { |
| 45 | label: "react-modal and react-router.", |
| 46 | app: App |
| 47 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected