solid-router icon indicating copy to clipboard operation
solid-router copied to clipboard

RouteSectionProps allows children, but why?

Open TPReal opened this issue 2 years ago • 2 comments

Describe the bug

The RouteSectionProps type allows children. This creates two small problems:

  1. I declare my pages as VoidComponent as they cannot have children, they are the whole page components, and right now passing them as the component doesn't compile.
  2. Why allow specifying children at all? How would I specify children to a component used in a route? Does it even make sense?

Your Example Website or App

https://stackblitz.com/edit/solidjs-templates-pheug1?file=src%2FApp.tsx

Steps to Reproduce the Bug or Issue

It just doesn't compile, without a good reason, I think.

Expected behavior

It compiles fine when given a VoidComponent.

Screenshots or Videos

No response

Platform

  • OS: *
  • Browser: *
  • Version: 0.10.5

Additional context

It is a recent change, it used to work reasonably on 0.10.1 I think.

TPReal avatar Jan 04 '24 12:01 TPReal

If you have a suggestion for the types I'd love it, but its because route sections can have children in that is how outlets work. You inject nested route sections via props.children. So the general type for RouteSectionProps needs to at least have the potential of accepting children I think.

ryansolid avatar Jan 04 '24 19:01 ryansolid

I see. So the component should be able to accept children, but actually only if the Route element has children, right? Sounds like it's quite possible to declare the types like this.

TPReal avatar Jan 07 '24 12:01 TPReal