강의

멘토링

커뮤니티

Inflearn Community Q&A

rlaqud9k6721's profile image
rlaqud9k6721

asked

Node and React series that you can learn by following - Basic lecture

Node React Basics Lecture #31 Membership Registration Page

리다이렉트 오류가납니다 ㅠㅠ

Written on

·

1.4K

1

×

Unhandled Rejection (TypeError): Cannot read property 'push' of undefined
(anonymous function)
C:/Users/rlaqu/OneDrive/Desktop/boiler-plate/client/src/components/views/RegisterPage/RegisterPage.js:50
  542 | };
543 | dispatch(Object(_action_user_action__WEBPACK_IMPORTED_MODULE_2__["registerUser"])(body)).then(response => {
544 | if (response.payload.success) {
> 545 | props.history.push('/login');
| ^ 546 | } else {
547 | alert('failed to sign up');
548 | }
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error. Click the 'X' or hit ESC to dismiss this message.
회원가입결과 true가 리턴되는건 확인했는데요 리다이렉트부분이 먹통입니다 ㅠㅠ
뭐가 문제일까요??
reactnodejs

Answer 2

1

John Ahn님의 프로필 이미지
John Ahn
Instructor

혹시  withRouter 란것 쓰셨나요 ~ ?

마지막줄에  

export default withRouter(RegisterPage)

이걸로 감싸주셔야 합니다 

그리고 withRouter는 

import { withRouter } from 'react-router-dom';

이렇게 가져와주시면 됩니다 ~! 

0

rlaqud9k6721님의 프로필 이미지
rlaqud9k6721
Questioner

아 마지막줄에 감싸줘야하는거군요 감사합니다

이제 제대로 돌아가는 페이지를 보니 가슴이 웅장해지네요 ㅠㅠ

rlaqud9k6721's profile image
rlaqud9k6721

asked

Ask a question