I'm working on a personal project and i have now been stuck with a react router problem since a couple of day.
I'am fetching an API and trying to render a route with a single id so when i click on the card link everything is working fine but as soon as a try to render the link manually on a new tab for example i got a console error
TypeError: Cannot read property 'position_name' of undefined
| const Articles = ({ location }) => (
5 | <ArticleComponent
> 6 | position_name={location.state.position_name}
7 | workplace_name={location.state.workplace_name}
Here are my routes on the APP.js file
<Switch>
<Route exact path="/" component={JobCard} />
<Route path="/jobs/:_id" component={Articles} />
</Switch>
and the component where i fetch the card.
<div key={job._id} className="blog-card">
<div className="description">
<Link
className="link-apply"
to={{
pathname: `/jobs/${job._id}`,
state: job
}}
>
<h5 className="position-name">{job.position_name}</h5>
<p className="place">{job.workplace_name}</p>
<p className="location-job">{job.location}</p>
</Link>
</div>
So what i'm trying to achieve is to be able to render the articles when i type the link manually, for example: http://localhost:3000/jobs/5ccc770c6ac54350001f0954
But it's only rendering when i click on the card for some reasons.
Thanks in advance for the help