score:2

In complement of @juliangonzalez (good) answer:

Better to make your component not "route" aware, so instead of passing React match object you should do:

<Route path="/:id" render={({match}) => 
    <RunningProject getProjectById={this.getProject} projectId={match.params.id} />
} />

score:28

In order to pass the match object you need to deconstruct the object passed as parameter to the render callback like this:

<Route path="/:id" render={({match}) => <RunningProject getProjectById={this.getProject} match={match} />} />

You can also get the other objects, here's a list of the objects passed:

  • history
  • location
  • staticContext
  • match

Or you could just pass the whole object, and deconstruct in the recipient component

<Route path="/:id" render={(obj) => <RunningProject getProjectById={this.getProject} obj={obj} />} />


Related Query

More Query from same tag