Skip to content

CSSTransitionGroup throws when a child returns null from render #2619

Closed
@johanneslumpe

Description

@johanneslumpe

I came across this, when using react-router. When loading a route initially where the route handler is actually inside a ReactCSSTransitionGroup and then removing it from the transition group leads to an Uncaught TypeError: Cannot read property 'addEventListener' of null. The weird thing is that it only happens on initial load of a nested route, not when the same view is being pulled up via the menu. I'm not sure if this is an issue related react-router or if it belongs to react. But the thing is that the RouteHandler component either returns a react element, or it returns null. It seems like an edge case maybe, because it only happens in this specific initial render setup.

It could be fixed, by adding a guard to the transition() method of ReactCSSTransitionGroupChild:

if (!node) {
  finishCallback && finishCallback();
  return;
}

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