I'm using tmdb api multi search, I have a get request that returns back an array of items which have an object key and value. Some return 'media_type: tv', some return 'media_type: movie' I have two different routes set up for each of these.
Heres my App structure
<BrowserRouter>
<div className='App'>
<Switch>
<Route path='/' exact component={Home} />
{/* <Route exact path='/details/:type/:id' component={ItemDetails} /> */}
<Route exact path='/details/movie/:id' component={MovieDetails} />
<Route exact path='/details/tv/:id' component={TvDetails} />
</Switch>
</div>
</BrowserRouter>
Get Request
` performSearch = () => { // Requesting data from API
let now = (this.now = Date.now());
axios.get(`${URL}api_key=${API_KEY}&language=en-US&query=${this.state.searchInput}${PARAMS}`)
.then((res) => {
console.log(res.data.results);
// Accepting response if this request was the last request made
if (now === this.now) {
this.setState({ searchResults: res.data.results});
}
});
}`
Functional Component that renders search result items
const Suggestions = (props) => {
const options = props.searchResults.map(r => (
<li
key={r.id} >
<Link key={r.id} to={`/details/${r.id}`}>
<a href='#t' className='rating'><i className='fas fa-star fa-fw' />{r.vote_average}</a>
<img src={`https://image.tmdb.org/t/p/w185/${r.poster_path}`} alt={r.title} className='search-results-poster' />
<a href='#t' className='search-results-name'>{r.name}</a>
<a href='#t' className='search-results-title'>{r.title}</a>
</Link>
</li>
))
return <ul className='search-results'>{options}</ul>
}
I'm thinking something like if(props.media_type === tv){<Redirect component={TvDetails}/> else {<Redirect component={MovieDetails}, I'm new to react-router so I'm not sure on how to do this
I have tried <Link key={r.id} to={/details/${props.searchResults.media_type.value}/${r.id}}>
but it says value is undefined though I can see it in my console.log 
edit: <Link key={r.id} to={/details/${r.media_type.value}/${r.id}}>
Takes me to /details/undefined/1234 , So I guess the value is still undefined?
/details/${r.media_type}/${r.id}}> Thanks though