-
Notifications
You must be signed in to change notification settings - Fork 291
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
RFC: Cannot pass react.VFC typed component to withAuthUser argument #142
Comments
I actually came here to open a similar issue. If you use Next.js' provided
Here is a basic example.
I will note that it does work if I type the page as just It's a hard call to make - whether React types or next-firebase-auth types need updating. I am leaning towards thinking that it would make sense for this library to have broader support with this function, especially given that there seems to be two common types that do not work here. However... FULL DISCLOSURE: I am not a TS expert! This is my first TS project, so my viewpoint may be a little skewed. |
Thanks for this issue! I welcome suggestions from people who have more experience with TS than I do. At a glance, it seems like switching to |
I was going to request thing same thing after reading https://fettblog.eu/typescript-react-why-i-dont-use-react-fc/, as my pages return Looking at other GitHub repos, |
I converted one of the example pages to TypeScript and ran into a similar issue when using a normal function for the functional component: |
I'm also stuck on how to use I personally see the following error when trying to type my
|
It is a little messy having to declare the |
Interestingly enough this also works with
|
Added some details on the use of TypeScript with `withAuthUser` method.
#142: TypeScript and `withAuthUser`
Describe the bug
Since
withAuthUser
argument type isreact.ComponentType
(ref:next-firebase-auth/index.d.ts
Line 95 in e5e4717
react.VFC
cannot be passed.However, IDK which is better, to fix next-firebase-auth type definition or DefinetelyTyped react type definition.
If you have any suggestions, please let me know.
Version
0.12.2
To Reproduce
Pass
react.VFC
typed component towithAuthUser
argument.Expected behavior
Does not produce type error.
Additional context
(About
react.Component
)react.ComponentType
definition:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L78
This lacks
react.VoidFunctionalComponent
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L539-L555
(About
react.VFC
)Currently, with
react.FC
typed component seems implicitly receiving children.So React team recommends to use
react.VFC
(which we have to write children explicitly when we want), and from React v18react.FC
will be modified behaviorally equivalent toreact.VFC
.The text was updated successfully, but these errors were encountered: