-
Notifications
You must be signed in to change notification settings - Fork 55
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
Can't use PropsWithChildren on route components #650
Comments
I believe your solution with defining I think it's nicer than One minor quibble – the typing on |
Thanks for the response. I was under the impression
I have a footnote in my comment speaking to that. If I type |
With Actually, that's what's making your initial example not work as well, now that I look at the error. The type we have is "any component type" anyway: Lines 280 to 283 in e24d9cc
There's no need to use any defined type here, because Found doesn't expect anything of the component. It just provides props to the component, but that's not represented in the typings here, even. |
Thanks for clarifying. My confusion around the types stemmed from |
No worries. Good luck! |
I may be doing something wrong, but I've tried to write a functional component for the router that accepts the router state from found and provides access to the children:
Unfortunately, that raises the following TypeScript error:
I'm still fairly new to both TypeScript and React, so maybe I'm just overlooking something. But, I don't see how my component doesn't adhere to found's type signature. Following on from that, I don't see a way to make my component match the type signature.
My solution for the time being is to replace
PropsWithChildren
with a new interface defining my props like so:This approach works fine*. TypeScript is happy and I can access the fields I'd like. It'd be nice to be able to use
PropsWithChildren
, however, just to maintain consistency in my code.children
field; if I mark itReactNode
, this interface will result in a similar error.The text was updated successfully, but these errors were encountered: