Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redux handling loading => api 단위가 아닌 id 단위로 이뤄졌을 때 #7

Closed
yjkwon07 opened this issue Jun 20, 2021 · 0 comments
Labels
redux 리덕스 관련 문제 solution 솔루션 해결

Comments

@yjkwon07
Copy link
Owner

yjkwon07 commented Jun 20, 2021

상황

  • CRUD API가 특정 Id만 Edit(update, delete) 요청이 일어날 때, api를 watch하는 component 모두 loading이 일어난다.
  • 특정 id의 변화를 감지해야할 때, 해결하는 방법은?
  • 여기서 중요한점은, post 리듀서는 fetchStatus 리듀서와 분리 되어있다. (관심사 분리)
    • fetchStatus와 saga(helper)에서 조금만 건들면 해결점이 보인다.
  • 참고

해결

  • saga에서 meta 정보를 입력하도록 하는것이 좋을지, 아니면 컴포넌트에서 meta를 입력할지 고민이 된다.
  • 현재 내린 결론은 component에서는 actionList를 깜빡 할 수 있거나, 반복된 쿼리 데이터를 작성해야 하므로 saga에서 입력하도록 한다. => useFetchStatus 에서 loading을 알아야 하는단일 id 정보를 추가하여, id 상태를 확인할 수 있는 훅스를 만들고, 컴포넌트에서는 id값을 넣으면, 특정 Id status를 추적하고, id 정보가 아니면, fetch(api 단위)상태를 받게된다.

@yjkwon07 yjkwon07 added redux 리덕스 관련 문제 solution 솔루션 해결 labels Jun 20, 2021
yjkwon07 added a commit that referenced this issue Jun 21, 2021
- api 단위, id 단위로 나뉨
- actionList 추가
@yjkwon07 yjkwon07 closed this as completed Jul 4, 2021
yjkwon07 added a commit that referenced this issue Oct 9, 2021
- useFetchStatus 수정
  - useEffect 대신 usAppSelector에서 받아온 데이터로 data 반환
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
redux 리덕스 관련 문제 solution 솔루션 해결
Projects
None yet
Development

No branches or pull requests

1 participant