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

createPortal child ref callbacks are called AFTER componentDidMount #11621

Closed
ajhyndman opened this issue Nov 22, 2017 · 1 comment
Closed

createPortal child ref callbacks are called AFTER componentDidMount #11621

ajhyndman opened this issue Nov 22, 2017 · 1 comment

Comments

@ajhyndman
Copy link

ajhyndman commented Nov 22, 2017

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

When using the new ReactDOM createPortal API, adding a ref callback to the portal subtree is not fired until after componentDidMount in the current component.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).

https://codesandbox.io/s/lykxzopwj9

What is the expected behavior?

I expected ref callbacks in children rendered into a portal (like other children) to have been fired before the parent component's componentDidMount lifecycle method.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

I have tested versions of React from 16.0.0 to current (16.1.1), and they seem to share the same behaviour.

@ajhyndman ajhyndman changed the title React 16 createPortal createPortal child ref callbacks are called AFTER componentDidMount Nov 22, 2017
@ajhyndman
Copy link
Author

Ahh, this one is user error. I had a typo in my reduced test case, and I was misunderstanding the composition in the scenario I thought I ran into this at first.

createPortal is awesome so far! I'll close this.

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

No branches or pull requests

2 participants