반응형
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 |
Tags
- formik react-query submitting not working
- gitsquash
- 시스템설계면접팁
- 헤드퍼스트전략패턴
- 가상면접2장
- 시스템설계면접
- react
- Git commit 합치기
- 시스템설계면접예시
- 전략패턴
- awss3
- s3이미지다운로드됨
- git commit merge
- file not found Error
- 시스템설계방법
- 리팩터링2판테스트
- 테스트코드책
- 가상면접3장
- FirebaseAnalytics
- 가상면접으로대규모시스템
- git squash
- git commit 협업
- 시스템설계
- 디자인패턴
- cypress React
- cypressBDD
- 리액트구글애널리틱스
- react-ga
- formik submitting not working
- 리팩토링2판4장
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
velopert/learning-react
[길벗] 리액트를 다루는 기술 서적에서 사용되는 코드. Contribute to velopert/learning-react development by creating an account on GitHub.
github.com
'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 |