Open hatchling13 opened 3 years ago
Redux Store가 갱신되기 전의 값에 따라 웹사이트의 오류 문구 등이 적용되는 오류를 해결한다.
Redux Store
Redux의 dispatch를 통해 비동기적으로 Store의 값을 변경한다. 이 때, await 키워드를 통해 Store가 갱신되기를 기다렸다가 바뀐 값(이 경우 errorCode)에 따라 오류 문구를 보여준다. 그러나 errorCode가 원하는 때에 갱신되지 않아 이전 값에 따라 결과 처리가 진행된다.
Redux
dispatch
Store
await
errorCode
생각할 수 있는 원인은 다음과 같다:
async/await
useSelector
개요
Redux Store
가 갱신되기 전의 값에 따라 웹사이트의 오류 문구 등이 적용되는 오류를 해결한다.문제 상황
Redux
의dispatch
를 통해 비동기적으로Store
의 값을 변경한다. 이 때,await
키워드를 통해Store
가 갱신되기를 기다렸다가 바뀐 값(이 경우errorCode
)에 따라 오류 문구를 보여준다. 그러나errorCode
가 원하는 때에 갱신되지 않아 이전 값에 따라 결과 처리가 진행된다.생각할 수 있는 원인은 다음과 같다:
async/await
의 사용이 미숙하여 잘못 사용하였다.useSelector
의 갱신 시점이 올바르지 않다.