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

Using React 16 portals #554

Closed
brmenchl opened this issue Nov 3, 2017 · 3 comments
Closed

Using React 16 portals #554

brmenchl opened this issue Nov 3, 2017 · 3 comments

Comments

@brmenchl
Copy link

brmenchl commented Nov 3, 2017

React 16 now officially supports portals. Is there any plan to move from a custom implementation?

Portal documentation:
https://reactjs.org/docs/portals.html

@comfroels
Copy link

Do they use a custom implementation? From what the code says(https://github.com/reactjs/react-modal/blob/master/src/components/Modal.js#L11-L14), they look for react 16 and use the portals already. However, I am having an issue testing with that and enzyme; issue here (enzymejs/enzyme#1150). I'm wondering if there's a way for us to say we don't want to use portals if we don't want to (or if other libraries are having issues with it)

@diasbruno
Copy link
Collaborator

@brmenchl react-modal already has support for react 16 on version v3+.

@comfroels I think the best way (or at least for now) is to define an alias on your compiler config to use a dummy proxy component (which just returns the children or a <div>{children}</div>). This way you will "remove" the Modal from your tests.

Ref: Webpack resolve config
Ref: Rollup alias plugin

Another way would be to make the modal content a component itself.

Here is an example: https://codesandbox.io/s/lyqov0lowl

@diasbruno
Copy link
Collaborator

I'm close this for clean up. @comfroels Feel free to open a new issue or follow any other previously opened about testing. Thank you!

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

3 participants