Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSSTransitionGroup throws when a child returns null from render #2619

Closed
johanneslumpe opened this issue Nov 27, 2014 · 13 comments · Fixed by #4170
Closed

CSSTransitionGroup throws when a child returns null from render #2619

johanneslumpe opened this issue Nov 27, 2014 · 13 comments · Fixed by #4170

Comments

@johanneslumpe
Copy link
Contributor

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;
}
@sophiebits
Copy link
Collaborator

This was probably fixed by #2503.

@gaearon
Copy link
Collaborator

gaearon commented Mar 1, 2015

I don't think this is solved.

It's easy to reproduce with React 0.12.2: just have the child return null from render. It's rather frustrating because some other developer may change the animated component to return null when data is not ready, and not realize that this breaks the case when that component is inside the transition group.

@joshthecoder
Copy link

Yup ran into this as well. If you pass a component to ReactCSSTransitionGroup that renders null you get this exception. Using React 0.12.1

@gaearon
Copy link
Collaborator

gaearon commented Mar 6, 2015

@spicyj Can you please reopen?

@sophiebits sophiebits reopened this Mar 6, 2015
@sophiebits sophiebits changed the title Uncaught TypeError in CSSTransitionGroupChild CSSTransitionGroup throws when a child returns null from render Apr 1, 2015
@jarvanxing
Copy link

i've get the same exception, too. Hope this will be fixed soon.

@johanneslumpe
Copy link
Contributor Author

@spicyj is there anything stopping you people from implementing the suggested fix? :)

@felixakiragreen
Copy link

I'm encountering a similar issue.

@gaearon
Copy link
Collaborator

gaearon commented Jun 18, 2015

is there anything stopping you people from implementing the suggested fix? :)

I guess a PR would be welcome?

@johanneslumpe
Copy link
Contributor Author

@gaearon yeah, there is is!

@digitalmaster
Copy link

I'm still seeing this issue. And can verify that it only happens when I return null.

React with addons v0.13.3

@sophiebits
Copy link
Collaborator

Yes, the fix is in 0.14.

@digitalmaster
Copy link

Ahh.. well that would explain things.

How can I get my hands on 0.14?

@sophiebits
Copy link
Collaborator

Sorry – not released yet, but hopefully in the next few weeks. 0.14-beta is on npm (see the React blog).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants