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

RouteSectionProps allows children, but why? #347

Open
TPReal opened this issue Jan 4, 2024 · 2 comments
Open

RouteSectionProps allows children, but why? #347

TPReal opened this issue Jan 4, 2024 · 2 comments
Labels
typescript Related to TypeScript

Comments

@TPReal
Copy link

TPReal commented Jan 4, 2024

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.

@ryansolid
Copy link
Member

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.

@TPReal
Copy link
Author

TPReal commented Jan 7, 2024

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.

@ryansolid ryansolid added the typescript Related to TypeScript label Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
typescript Related to TypeScript
Projects
None yet
Development

No branches or pull requests

2 participants