6724

React router in TypeScript- both router and own props

Question:

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.

Answer1:

<strong>Fixed</strong> by changing

export default withRouter(Wizard);

to

export default withRouter<PropsType>(Wizard);

Recommend

  • React 16.7 - React.SFC is now deprecated
  • Multiple switches (toggels) enable all at once when generated from array react-native
  • Objects are not valid as a React child data from MongoDB
  • Inject JavaScript or CSS into React Native WebView before page renders
  • Cannot read property 'props' of null - Reactjs [duplicate]
  • Navigator with args
  • java write properties file
  • React Native - manipulate View to apply shadow to Image's BorderRadius?
  • Alert prompt to function not working in react native
  • How to avoid a jQuery call in ReactJS
  • Javascript snippet not working (missing lib?)
  • In Akka Java actor model, can a router create actors with non-default constructor?
  • How to use Animated.diffClamp in react native
  • Can wso2 data service return affected rows after SQL update?
  • React textarea with value is readonly but need to be updated
  • Javascript syntax null : ?{}
  • reset jquery smartwizard
  • Creating a setup.exe in InstallShield in Visual Studio
  • How can I reset dropdown data if modal closed on vue component?
  • Undefined navigator.push React-native 0.43.4
  • Highlight and Bold text in JTextPane
  • how to do an event when i swipe from fragment to the other
  • Web-crawler for facebook in python
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Akka Routing: Reply's send to router ends up as dead letters
  • Circular dependency while pushing http interceptor
  • Cannot Parse HTML Data Using Android / JSOUP
  • Linker errors when using intrinsic function via function pointer
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Java static initializers and reflection
  • unknown Exception android
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Unable to use reactive element in my shiny app
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal