[o] 아티클 생성, 수정 페이지 구현
[o] 아티클 Create 기능 구현
[o] 아티클 Update 기능 구현
[o] 아티클 Read 기능 구현
useForm 사용 시 전달해주는 onSubmit 함수에서 라우터 처리를 해버리면 onSubmit함수가 끝난 후 페이지가 넘어가 버리기 때문에 남아있는 로직(setErrors, setIsLoading)들이 실행되지 못해 오류가 발생한다
onSubmit: async values => { ... history.push(`/series/${id}`); },
const handleSubmit = async e => { setIsLoading(true); e.preventDefault(); const newErrors = validate(values); if (!newErrors || Object.keys(newErrors).length === 0) { const resErrors = await onSubmit(values); setErrors({ ...newErrors, ...resErrors, }); } else setErrors(newErrors); setIsLoading(false); };
useForm컴포넌트가 마운트 될 때 처리하지 못한 로직들이 종료되도록 useEffect에서 cleanUp함수를 반환해준다
useEffect( () => () => { setErrors({}); setIsLoading(false); }, [], );
공통된 pathname을 갖는 라우트들이 있을 때, 공통된 pathname바로 뒤에 동적 파라미터를 설정한 라우트가 가장 위에 위치하면 그 뒤에 오는 라우트의 마지막pathname이 첫번째 라우트의 동적 파라미터로 적용되어 원하는 컴포넌트가 렌더링 되지 않는다
(x)
<Route path="/series/:id" exact component={SeriesDetailPage} />
<PrivateRoute exact from="/series/write" component={WriteSeriesPage} />
<PrivateRoute exact from="/series/edit/:id" component={EditSeriesPage} />
(o)
<PrivateRoute exact from="/series/write" component={WriteSeriesPage} />
<PrivateRoute exact from="/series/edit/:id" component={EditSeriesPage} />
<Route path="/series/:id" exact component={SeriesDetailPage} />
- 오류 잡기에 시간이 너무 들어가서 진도가 늦어졌다
- 1차 스프린트 때 만든 기능을 너무 급하게 만들어서 리팩토링에 시간이 많이 걸린다
- 1차 스프린트 때 만든 기능을 너무 급하게 만들어서 리팩토링에 시간이 많이 걸린다
- 전체적인 폴더구조나, 라우터 등등 리팩토링 할 것들이 너무 많아서 진도를 못나갔다
- 브런치 관리
- 코드 컨벤션
- 일관성
- 코드리뷰
함수 실행과 렌더링 과정의 순서에 대해 좀 더 잘 알게되어서 1차 스프린트 때 해결하지 못한 기능을 구현하거나 오류를 해결할 수 있었다
시간에 쫒겨서 되는대로 구현하지 말고 기간을 못지키더라도 어느 정도는 차근차근 수시로 리팩토링 해가며 코드 짜기