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

React 16 - unstable_renderSubtreeIntoContainer does not always return an instance #10310

Closed
jlongster opened this issue Jul 27, 2017 · 2 comments

Comments

@jlongster
Copy link
Contributor

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

A bug

What is the current behavior?

I am using the react-modal library and tested it under React 16 beta. It throws an error when I try to close the modal.

The reason is it calls renderSubtreeIntoContainer here and expects an instance back. But sometimes it's null, so when it's closing and it's trying to read it's state here you get a null reference error.

If you use the API like <Modal isOpen={this.state.open} /> is works, but only because the component never tries to read from this.portal. If you use it like this.state.open && <Modal /> you get the error, because it tries to read it in componentWillUnmount: https://github.com/reactjs/react-modal/blob/master/src/components/Modal.js#L132

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: https://jsfiddle.net/84v837e9/).

https://github.com/jlongster/fiber-modal-error

What is the expected behavior?

renderSubtreeIntoContainer should always return an instance so this modal librarly works (it will close).

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

React 16 beta. It works in all previous versions.

@gaearon
Copy link
Collaborator

gaearon commented Jul 27, 2017

Fairly sure it's same issue as #10309.

@gaearon
Copy link
Collaborator

gaearon commented Jul 27, 2017

Let's track there. (But I'll verify that fix also fixes your example)

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