useHistory1 [React]함수형 컴포넌트에서의 this.props.history.push(); MEGAFOX 프로젝트 리팩토링 class 컴포넌트로 작업한 부분을 함수형 컴포넌트로 수정 진행 중. :: class component -> function component 🤓 이 때, onClick 이벤트 시 페이지 이동을 위해 사용했던 함수형은 state 없는데, this.props를 사용할 수 있나요? 컴파일부터 안됩니다. this.props.history.push(경로); 를 더이상 사용할 수 없었다. goToTheater = () => { const { history } = this.props; history.push('/theater/list'); }; react-router v5를 기반으로 설명 합니다. (v6버전 관련 내용 포스팅, 공식문서) [ 해결 ] 함수형에서 push메서드를 사용해.. 2021. 11. 8. 이전 1 다음