Unexpected behavior with child components with a single slot #657
Labels
Content-Length: 242964 | pFad | https://github.com/purescript-halogen/purescript-halogen/issues/657
2EFetched URL: https://github.com/purescript-halogen/purescript-halogen/issues/657
Alternative Proxies:
Recently encountered an issue with child components that just slot in other components. Here's what the component tree looks like:
In the router, the "home" and "about" slots should never both be rendered, like
this:
But after routing from home to about, I get both home and about rendered in the
.should-only-have-one-child
div.What's triggering the issue is that the Home/About components that the router is
rendering are just slots for their "inner" components. In the example this
doesn't make much sense but in my real code I have that outer component
providing some input to the child component (the parent component is sorta like
the redux connect HOC in react).
Wrapping the inner component's slot in a div fixes the issue:
Anyway, I'm sure this hasn't done a great job of explaining the issue, I made a
repo with a reproduction of the issue: https://github.com/marcusbuffett/halogen-slots-issue
And here's a PR with the div fix mentioned above: https://github.com/marcusbuffett/halogen-slots-issue/pull/2/files
The example code does use hooks, but it's not a hooks issue, converting the parent components to "plain" components causes the same issue.
The text was updated successfully, but these errors were encountered: