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

breaks on 10.0.0-alpha.* #18

Open
shirotech opened this issue Apr 2, 2019 · 2 comments
Open

breaks on 10.0.0-alpha.* #18

shirotech opened this issue Apr 2, 2019 · 2 comments

Comments

@shirotech
Copy link

shirotech commented Apr 2, 2019

This is due to how render doesn't append new dom anymore if it's being rendered already, also this.props.children is not always an array. I had a go at fixing it by doing some workaround like:

this.remote = this.props.into.appendChild(document.createElement('div'));

But then I don't know Preact well enough to render directly into that remote, render will render inside the div only. Not the current behaviour.

@shirotech shirotech changed the title 10.0.0-alpha.* breaks on 10.0.0-alpha.* Apr 2, 2019
@chinchang
Copy link

chinchang commented Jul 16, 2019

Hey @developit
Any pointers that you can give so that we can make this work on our side with Preact X?

For now, this is my working hack:

  • In my preact-portal fork, before accessing children[0] I convert it to an array like so:
const arr = toChildArray(children); 
return (arr && arr[0]) || null;
  • In my components that use Portal (modals), I append a new container for each instance which I provide to the Portal too. And remove that container on unmount.

@shirotech
Copy link
Author

Seems like this project is no longer maintained? In PreactX we can now use createPortal from preact/compat.

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

No branches or pull requests

2 participants