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

(fix) - portals 2.0 #1713

Closed
wants to merge 23 commits into from
Closed

(fix) - portals 2.0 #1713

wants to merge 23 commits into from

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Jun 13, 2019

Current problems

Initial render

I moved this to a solution where we prepend children to the root's _children array and after that call forceUpdate since roots are components. This in theory could be a good approach but when we initially render, forceUpdate won't do anything, since _vnode etc isn't defined yet. (I have tried setting an empty state didn't work either).

Inserting multiple roots

Our former solution where we used hydrate('', container) makes it so that the second insertion hydrates the first portal. This in turn makes it so that we can't unmount the first one with render(null, container) anymore. This was a signifier that we should avoid using hydrate for portals.

Switching container

At the moment I rely on render(null, container) to work, in theory this should be good enough for the time being but when we have a better solution we should test more thorough.

Singular insertions

Note that the singular insertions at the moment are working since these fallback to hydrate and render, these tests are always on initial render etc so don't take these passes for granted.

How did we get here?

First we encountered the issue that we didn't insert portals, we made the assumption that portals were rendering into empty roots.
We solved this by prepending the portalChild, this in turn unmounted all children when using render(null, container). This was solved by using hydrate('', container).

I could really use a few pointers on this since I feel like I've been going in the same circle for a while now.

Test cases added for the new issue report, thanks to @MichaelRando for the reproductions

Found a missing case to allow changing container, these two failing tests leave me jumbled though.
Been researching the hint provided about Fragments but this feels like odd behavior

  • support switching container
  • support multiple portals in one root
  • avoid irrelevant children from rerendering

@coveralls
Copy link

coveralls commented Jun 13, 2019

Coverage Status

Coverage increased (+0.5%) to 99.565% when pulling 6f409b7 on fix/portals2.0 into 65af849 on master.

compat/src/index.js Outdated Show resolved Hide resolved
src/render.js Outdated Show resolved Hide resolved
@JoviDeCroock
Copy link
Member Author

Closing this due to remake

@JoviDeCroock JoviDeCroock mentioned this pull request Jul 1, 2019
5 tasks
@JoviDeCroock JoviDeCroock deleted the fix/portals2.0 branch October 10, 2019 23:11
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 this pull request may close these issues.

4 participants