Skip to content

Modal content failing to update properly with React Router #499

Open
@KyleJSummers

Description

@KyleJSummers

Summary:

I'm trying to do routing within a react-modal modal using React Router. I noticed an issue where route-based content requires two clicks of a link to display when rendered in a react-modal modal. To clarify what I mean by this, please check out the following example where I've isolated the pieces to a minimal to reproduce it.

https://codesandbox.io/s/yvnkj1zvzj

Steps to reproduce:

  1. Click the "Modal" link
  2. Click Link 1 (expected: it updates to show the content; actual: no update is observed)
  3. Click Link 1 again (content gets updated)

You can toggle between the two links, but it always seems to take an additional click after the URL updates for the content to update.

Expected behavior:

Content should update with the URL updates.

Link to example of issue:

https://codesandbox.io/s/yvnkj1zvzj

Additional notes:

I thought this might have to do something with react-modal pulling the components out of the flow, but I'm not sure. I tried specifying the prop for a parent container that was within the router subtree but that didn't seem to help. I wonder if it might be something with the use of ReactDOM.unstable_renderSubtreeIntoContainer with react-modal, but I'm really not sure.

Is routing within a react-modal modal not a use case that is readily supported? The example I prepared works if the modal is replaced with a simple wrapper component, so I'm quite confident the issue is somewhere within react-modal.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions