I'm having following json file,
[
{
"id" : 7,
"intro": "intro_7"
},
{
"id" : 8,
"intro": "intro_8"
}
]
Then I'm trying to filter one of object from above json file, Thats I'm trying to this following way.
import React,{ useState, useEffect} from 'react';
import source_data from '../source/data.json';
function CardIntro(props){
let {selectedItem} = source_data.find(item => item.id == 8);
return(
<div> Card Intro </div>
<div>{selectedItem.intro}</div>
)
}
export default CardIntro;
I'm getting the following error, what is missing here
TypeError: Cannot read property 'intro' of undefined
I tried to use .filter also not successful
{id:8,intro:"intro_8"}