learning-react
learning-react copied to clipboard
개정판 P. 347 ~ 348 withRouter
이건 오탈자가 아닐수도 있습니다만 왜 withRouter를 사용하여 컴포넌트를 반환하는지 잘 이해가 안되어 질문 합니다.
Profiles.js
...
import WithRouterSample from './WithRouterSample';
...
P. 347 내용 중 WithRouterSmaple 컴포넌트를 Profiles에서 지우고 Profile 컴포넌트에 넣으면... (생략)
Profile.js
...
import { withRouter } from 'react-router-dom';
import WithRouterSample from './WithRouterSample';
...
export default withRouter(Profile);
...
분명 본문에는 Profiles.js에서 삭제한 후 Profile.js에 옮기라고만 되어 있는데 import와 export에 추가된 코드들이 보입니다. 혹시나 해서 withRouter를 import하지 않고 export 문에서도 withRouter를 삭제했는데 별 무리없이 작동됩니다. 혹시 제가 놓친게 있을까요??