function Detail(props){
let {id} = useParams(); //App.js에서 사용한 파라미터 가져오기
let 찾은상품 =props.shoes.filter(function(x){
return x.id = id
});
return(
<div className="container">
<div className="row">
<div className="col-md-6">
<img src="https://codingapple1.github.io/shop/shoes1.jpg" width="100%" />
</div>
<div className="col-md-6">
<h4 className="pt-5">{찾은상품[id].title}</h4>
<p>{찾은상품[id].content}</p>
<p>{찾은상품[id].price}</p>
<button className="btn btn-danger">주문하기</button>
</div>
</div>
</div>
)
}
위의 조건식에서 x.id = id 하면 오류없이 잘 작동되는데
x.id == id 나 x.id === id로 하면
Cannot read properties of undefined오류 뜹니다.
근데 두 개 체크해서 타입확인해보니 x.id는 number , id는 string나와서
id 타입을 숫자로 변환하고 == 나 === 사용해도 같은 오류가 뜨는데
혹시 제가 어떤 실수를 한걸까요