2025. 5. 13. 09:45
import React from 'react';
class DetailPage extends React.Component {
componentDidMount() {
this.unlisten = this.props.history.listen((location, action) => {
if (action === 'POP') {
// 뒤로가기 또는 앞으로가기 등 브라우저 조작 감지
this.backToList();
}
});
}
componentWillUnmount() {
if (this.unlisten) {
this.unlisten();
}
}
backToList = () => {
console.log('뒤로가기 감지됨 - 목록 처리');
// 목록 초기화 또는 상태 복원 등 수행
};
render() {
return <div>상세 페이지입니다</div>;
}
}
export default withRouter(DetailPage);