Skip to content
This repository was archived by the owner on Oct 26, 2018. It is now read-only.
This repository was archived by the owner on Oct 26, 2018. It is now read-only.

Invariant Violation: Unable to find element when using middleware and conditionally rendering <Link> #244

@lukekarrys

Description

@lukekarrys

I ran into this error in an application of mine, but didn't think it was a bug at first. I was able to create a reduced test case, but I could just be doing something wrong. The error goes away if I remove the react-router-redux middleware, but I'm still not exactly sure why the error is happening.

Here's the gist with the reduced test case (apologies as its still pretty complicated). The two parts that I can edit to get around the error are removing the middleware and rendering somethings besides a Link.

Here's a brief explanation of what I'm trying to do:

  1. Render a redux connected component (<Page>) that has a loading indicator at /page/:param
  2. Once the <Page> is done loading its "data" (which is just a setTimeout in the gist) render some elements conditionally based on this.props.params.param
  3. Navigate from /page/1 to /page/2

What I'm seeing is that if the conditionally rendered element is a <Link> I get an invariant violation when navigating from /page/1 to /page/2. If I either change the <Link> element to something else (like an <a> or <span>) or remove the middleware then the error goes away.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions