Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…arting in 3.6.2) (#38326) * Make withRouter compatible with ComponentType Fixes #38271. * Add new baselines Co-authored-by: Oliver Joseph Ash <oliverjash@gmail.com>
- Loading branch information
Showing
2 changed files
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 37d97cd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@orta , @karol-majewski , @OliverJAsh , Hey sorry for posting here, i am not sure if this is the best place to do so either but I cannot find an anwer to my issue.
I was using withRouter
and typed it this way:
interface IProps extends RouteComponentProps<{}> {
onSubmit: (password: string, firstName: string, lastName: string) => void;
}
const SetPasswordForm = (props: IProps) => {
...
}
export default withRouter(SetPasswordForm);
This was working until this commit. Error is:
Argument of type '(props: IProps) => Element' is not assignable to parameter of type 'ComponentType<RouteComponentProps<{}, StaticContext, any>>'.
Type '(props: IProps) => Element' is not assignable to type 'FunctionComponent<RouteComponentProps<{}, StaticContext, any>>'.
Types of parameters 'props' and 'props' are incompatible.
Property 'onSubmit' is missing in type 'RouteComponentProps<{}, StaticContext, any> & { children?: ReactNode; }' but required in type 'IProps'. TS2345
93 | };
94 |
> 95 | export default withRouter(SetPasswordForm);
I'm not a typescript ninja yet, and my research have led me nowhere. Is there something that I am doing wrong?
Pease, add any or mixable type instead RouteComponentProps --> type RouteComponentProps & any. My custom props typing doesnt work with withRouter. Fix it please!!!
test it: