Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of using react-router query utils
import Modal from 'react-modal';
import { addQuery, removeQuery } from './utils-router.js';
const OPEN_MODAL_QUERY = 'openModal';
function SomeComponent({ location }) {
return <div>
<button onClick={ () => addQuery({ OPEN_MODAL_QUERY : 1 })}>Open modal</button>
isOpen={ location.query[OPEN_MODAL_QUERY] }
onRequestClose={ () => removeQuery(OPEN_MODAL_QUERY) }>
<h1>Modal Content</h1>
// inject "location" property from react-router
// to correct server-side rendering of opened modal
export default withRouter(SomeComponent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.