micnyk
micnyk

Reputation: 746

React router in TypeScript- both router and own props

my component has some own props

class Props {
  wizard: WizardConfig;
}

and I want to access router history so I also pass router props

type PropsType = Props & RouteComponentProps<{}>;

class Wizard extends React.Component<PropsType> {}

The problem is that in component's usage

 <Wizard wizard={someWizar} />

I get errors that RouteComponentProps props are not passed so for example: Property 'match' is missing in type '{ wizard: WizardConfig; }'

I tried to do:

export default withRouter(Wizard);

but it didn't help.

Upvotes: 1

Views: 1637

Answers (1)

micnyk
micnyk

Reputation: 746

Fixed by changing

export default withRouter(Wizard);

to

export default withRouter<PropsType>(Wizard);

Upvotes: 3

Related Questions