티스토리 뷰
<Route path="/detail/:id" element={
<Detail shoes={shoes}></Detail>
} />
이렇게 url 중에 :id를 넣으면
import { useParams } from "react-router-dom";
function Detail(props){
let {id} = useParams();
console.log(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">{props.shoes[id].title}</h4>
<p>{props.shoes[id].content}</p>
<p>{props.shoes[id].price}</p>
<button className="btn btn-danger">주문하기</button>
</div>
</div>
</div>
);
}
export default Detail;
useParam();을 이용해서 받을 수 있다.
'dev_공부일지 > React' 카테고리의 다른 글
Lifecycle (0) | 2024.02.26 |
---|---|
styled-component (0) | 2024.02.26 |
리액트 페이지마다 url 나누기 +404만들기 (1) | 2024.02.26 |
import,export (0) | 2024.02.23 |
input 다루기 (0) | 2024.02.23 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 항해플러스
- 향해99
- 컨트
- 리터럴
- 스프링공부
- SpringBoot
- 인터셉터
- 스프링부트
- JPA
- react실행
- ArgumentResolver
- 백엔드 개발자 역량
- 백엔드 개발자 공부
- exception
- 로그인
- hypertexttransferprotocol
- thymleaf
- BindingResult
- React
- Intercepter
- 예외처리
- HTTP
- reject
- 향해플러스백엔드
- rejectValue
- Java
- jpa api
- filter
- 항해99
- 향해플러스
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
글 보관함