공통점
- url이 변경되어 다른 페이지로 이동한다.
차이점
HTTP 요청
history.push ❌
window.location.href ⭕
새로고침
history.push ❌
window.location.href ⭕
Application 상태 유지(리액트 state 등)
history.push ⭕
window.location.href ❌
사용법
history.push('/');
window.location.href = '/';
url 변경, 페이지 이동시에 새로고침이 필요한 경우는 window.location.href를 사용하자!
'리액트 기초 > Routing' 카테고리의 다른 글
react-router-dom v6 (0) | 2022.06.08 |
---|---|
SPA/라우팅 (0) | 2022.06.03 |
react-router-dom v5 (0) | 2021.07.22 |