<h1><오류내용></h1>
TypeError: history.push is not a function
onClick
C:/Users/나/Desktop/코딩애플/리액트수업/shop/src/App.js:125
122 | let history = useHistory;
123 |
124 | return(
> 125 | <div className="col-md-4" onClick={()=>{ history.push('/detail/'+ props.shoes.id) }}>
| ^ 126 | <img src={'https://codingapple1.github.io/shop/shoes' + (props.a + 1) +'.jpg'} width="100%"></img>
127 | <h4>{props.shoes.title}</h4>
128 | <p>{props.shoes.content}&{props.shoes.price}</p>
View compiled
▶ 19 stack frames were collapsed.
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error. Click the 'X' or hit ESC to dismiss this message.
<h1><코드></h1>
<strong>(부모 컴포넌트)</strong>
<div className="container">
<재고context.Provider value={재고}>
<div className="row">
{
shoes.map(function(i,a){
return <Gift shoes={shoes[a]} a={a}/>
})
}
</div>
</재고context.Provider>
<strong>(자식컴포넌트)</strong>
function Gift(props){
let 재고 = useContext(재고context);
let history = useHistory;
return(
<div className="col-md-4" onClick={()=>{ history.push('/detail/'+ props.shoes.id) }}>
<img src={'https://codingapple1.github.io/shop/shoes' + (props.a + 1) +'.jpg'} width="100%"></img>
<h4>{props.shoes.title}</h4>
<p>{props.shoes.content}&{props.shoes.price}</p>
<p>{재고[props.a]}</p>
</div>
)
}
강의 그대로 따라 쳤는데, 메인에서 상품 이미지 클릭 했을 때 저런 오류가 뜨네요.
어떻게 해야 할까요..?