You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
위 코드에서 selectedDates 값은 화면에 표시되는 값이 아닌 api 형식에 맞게 변환시키기 위한 값임
따라서 아래의 과정을 거친다.
state로 관리하는 것이 아닌 일반 변수로 관리한다. (렌더링에 영향을 주지 않기 위해)
값이 변경될 때마다 값을 포맷팅시키는 것이 아니라 time과 date를 따로 관리한다.
request 요청을 보낼 때 resolver 레이어에서 비로소 useEffect에서 하던 동작을 실행한다. (useEffect 사용x)
resolver 레이어는 아래와 같다.
after (resolver 적용 후)
constresolveCraeteUserRequest=()=>{letdates=캘린더에서active된값들;// ['2023-08-31', '2023-09-01']if(!dateOnly){// YYYY-MM-DD hh:mm 형식으로 맵핑dateWithTime=[];timeBlock.map((itemList,timeIndex)=>{itemList.filter((item,dateIndex)=>{constdate=dateList[dateIndex]+' '+timeList[timeIndex];item&&dateWithTime.push(date);});dates=dateWithTime;});}// 이후 requestCreateUser 동작 실행}
The text was updated successfully, but these errors were encountered:
요약
state로 관리될 값과 전역상태로 관리되어야할 값 그리고 일반 변수로 사용해야할 값을 명확하게 구분하자.
resolver 활용 예시
before (resolver 적용 전)
위 코드에서
selectedDates
값은 화면에 표시되는 값이 아닌 api 형식에 맞게 변환시키기 위한 값임따라서 아래의 과정을 거친다.
resolver 레이어
에서 비로소 useEffect에서 하던 동작을 실행한다. (useEffect 사용x)after (resolver 적용 후)
The text was updated successfully, but these errors were encountered: