1

I am passing a prop in react route component as listed below:

<Route exact 
       path='/' 
       component={HomePage} 
       display_notification={this.display_notification.bind(this)} 
/>

But When I print the props of HomePage I cannot find display_notification.

Please help.

I am using react-router-v4

Adam LeBlanc
  • 932
  • 7
  • 21
sam23
  • 589
  • 2
  • 7
  • 23

1 Answers1

4

Route does not recompose props for you, it passes internal location related props only. you need to use the render={} API - https://reacttraining.com/react-router/web/api/Route/render-func

so something like

<Route exact 
  path='/' 
  render={() => <HomePage display_notification={this.display_notification} />} />
Dimitar Christoff
  • 26,147
  • 8
  • 50
  • 69