반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 시스템설계면접팁
- formik react-query submitting not working
- cypress React
- 시스템설계방법
- gitsquash
- 테스트코드책
- 시스템설계면접
- 리액트구글애널리틱스
- react-ga
- file not found Error
- 전략패턴
- 시스템설계면접예시
- 가상면접3장
- cypressBDD
- Git commit 합치기
- git squash
- FirebaseAnalytics
- s3이미지다운로드됨
- 리팩토링2판4장
- 가상면접2장
- git commit merge
- 시스템설계
- 헤드퍼스트전략패턴
- 리팩터링2판테스트
- awss3
- formik submitting not working
- 디자인패턴
- 가상면접으로대규모시스템
- git commit 협업
- react
Archives
- Today
- Total
mingg IT
[React] 뒤로가기, 홈으로 가기 History 이용 본문
뒤로 갈때
this.props.history.goBack();
홈으로 갈때
this.props.history.push("/"); 를 사용한다.
간단한 예제로는
import { Component } from 'react';
class HistorySample extends Component {
handleGoBack = () => {
this.props.history.goBack();
};
handleGoHome = () => {
this.props.history.push('/');
};
componentDivMount() {
this.unblock = this.props.history.block('정말 떠나실 건가요?');
}
ccomponentWillUnmount() {
if (this.unblock) {
this.unblock();
}
}
render() {
return (
<div>
<button onClick={this.handleGoBack}>뒤로</button>
<button onClick={this.handleGoHome}>홈으로</button>
</div>
);
}
}
export default HistorySample;
출처 : github.com/velopert/learning-react
'FrontEnd' 카테고리의 다른 글
[React] 웹팩(webpack) 과 create-react-app (0) | 2020.12.14 |
---|---|
[React] Context API (0) | 2020.12.08 |
[React, JavaScript] 비동기 처리 (0) | 2020.12.08 |
[React] NavLink (0) | 2020.12.08 |
[React] Error: node sass version 5.0.0 is incompatible with ^4.0.0. (0) | 2020.12.05 |
Comments