Consider the following JSON:
const JSON = [
{
"Name":"Ben Davies",
"JobsList":[
{
"Company":"Company1",
"Date":"01/01/01",
},
{
"Company":"Company2",
"Date":"01/01/01",
},
{
"Company":"Company3",
"Date":"01/01/01",
}
]
}
]
I want to pass the "Jobs" into a new component on the page, like so:
const [jobs] = useState(JSON);
return(
<CareerList
jobs={jobs}
/>
);
Now on the CareerList component, if I check the length of the jobs prop, I only get 1, I understand that this is because I'm not looping through the array, so how do I loop through the array? How do I make the length the desired 3 in this case.
const CareerList = (props) => {
const allJobs = props.jobs;
console.log(allJobs.length)
}
Thanks in advance.