0

I have this Route Configured.

<Router history={history}>
      <div>
         <NavBar />
     <Route path='/home' exact strict component={HomePageContainer} />
     <Route  path='/edit/:id' component={EditSchool}  />
       </div>
        </Router>

i want to access the value of the id which is dynamically passed to component EditSchool. This is my Link Tag

 <Link to={'edit/'+schools.id }> {schools.school_name}</Link>

This is what my URL looks like:

/edit/12

But how do I access the value 12, inside the component?

this.props.route

returns undefined.

Should I pass a prop to the route and then access it?

Please, someone, Help.

codemt
  • 413
  • 2
  • 9
  • 25

1 Answers1

1

You can access it with this.props.match.params.id.

Alex
  • 26
  • 2