Reputation: 5863
I have a react router set up like:
const routes = (
<Router>
<Route path={"audio" + "/:audio_url"} component={AudioView} />
<Route path="*" component={ErrorView} />
</Router>
)
Here I am passing my audio url like:
'play/3456'
when I pass access url like 'audio/play/3456'
it is redirecting me to ErrorView
.
It should redirect me to AudioView
right ?
What might be the issue here ??
Upvotes: 0
Views: 100
Reputation: 36787
Params don't span across URL fragments. If both play
and 3456
should be params, you should define them separately.
<Route path='audio/:command/:audio_url' component={AudioView} />
Upvotes: 0
Reputation: 5402
The route
<Route path={"audio" + "/:audio_url"} component={AudioView} />
matches only audio/123
You should include play
in the route
<Route path="/audio/play/:id" component={AudioView}>
Or if you are not sure of the route pattern add *
<Route path="/audio/*" component={AudioView}>
remember this matches anything after audio/
If possible prefer the first approach.
Upvotes: 2