this.props.matches are not received when a route is loaded from <Match> in PreactJs

126 Views Asked by At

Following is my code. All the necessary imports like Match are present in the file.

app.js

<Match path="/">
 if (path === '/registerParent') {
   return (<div><RegisterParent path="/registerParent"/></div>);
 }
</Match>
<Router>
 <Route1 path="/route1"/>
 <Route2 path="/route2"/>
</Router>

When I am routing the user to /registerParent using a button click, my route() function looks like this below :

routeUserToRegisterParent() {
  route('/registerParent?id=12345');
}

12345 is attached to the route as a query parameter.

The problem is, when I execute above code, it throws following error as it cannot find this.props.matches in the props object :

Cannot read property id of undefined.

But when I load my route from <Router> instead of <Match>, it works properly and this.props.matches is also received.

0

There are 0 best solutions below