[TIL] 11.07 router parameter

2019. 11. 7. 23:14TIL

오늘 한일

특정 Board의 container와 card 를 불러오기 위한 endPoint는 "boards/:id" 이다. id값을 클라이언트 라우팅 값으로 넣어 주기위해서 router parameter를 사용하였다.

 

router parameter

React router를 사용한 컴포넌트는 기본적으로 history, location, match 3가지의 props를 전달 받습니다.

3가지 props

 

  • history : push, replace 를 통해 다른 경로로 이동시키거나 앞 뒤 페이지로 전환이 가능하다.
  • location : 현재 경로에 대한 정보를 지니고 있다.
    (location.pathname => url 의 path / location.search => 쿼리스트링의 정보)
  • match : 해당 컴포넌트가 어떤 라우트에 매치되어 있는지에 대한 정보가 있다.
                  파라미터 정보를 params 속성으로 지니고 있다
    .

참고 블로그: https://pro-self-studier.tistory.com/76

 

'TIL' 카테고리의 다른 글

[TIL] 11.11 text input 으로 type변환  (0) 2019.11.11
[TIL] CSS  (0) 2019.11.10
[TIL] 11.6 react life cycle/ fetch  (0) 2019.11.06
[TIL] 11.05 client 사용자 인증  (0) 2019.11.05
[TIL]11.2 react-bootstrap  (0) 2019.11.02