T
TanStack2y ago
other-emerald

How to Fetch Specific Data for an ID in Details Component in React using React Router

I have navigated to
<Link to={`/city/id${city.id}`}> {city.name}</Link>
<Link to={`/city/id${city.id}`}> {city.name}</Link>
And in this component i want the whole object for that id, should i do a function to fetch the data again for that id or can i get the cached value? Since i just get the id from the params.
const CityDetailsPage = () => {
const params = useParams()

return <div>CityDetailsPage</div>
}

export default CityDetailsPage
const CityDetailsPage = () => {
const params = useParams()

return <div>CityDetailsPage</div>
}

export default CityDetailsPage
1 Reply
absent-sapphire
absent-sapphire2y ago
how does your query look right now ?

Did you find this page helpful?