codestates / codestates/Memory-It

[Error Handling] 리덕스 초기세팅을 했는데 페이지 렌더링이 안됩니다

Open
#70 0 comments 1 reaction 1 assignee Claimed by @rkems0122 View on GitHub
client Error!
Dominant language
JavaScript
Stars
1
Forks
2
PR merge metrics
No merged PRs in 30d

Description

### 어떤 에러인가요?
+ 리덕스 초기세팅을 했는데 아래의 메세지가 뜨면서 페이지 렌더링이 되지 않습니다.
### 에러 메시지
```
Uncaught Error: The slice reducer for key "loginReducer" returned undefined during initialization.
If the state passed to the reducer is undefined, you must explicitly return the initial state.
The initial state may not be undefined.
If you don't want to set a value for this reducer, you can use null instead of undefined.
```

### 에러 핸들링 방법
+ action, reducer, store는 정상적으로 등록이 되어있는 상태입니다.
+ 하지만 위 상태를 보면 상태가 undefined로 되어있습니다.
+ reducer부분에서 default 설정값을 설정하지 않아서 문제가 발생했습니다.(결과적으로 이거 한문단이 문제였음)
```
default:
return state // 여기서 state는 따로 작성해둔 initialState를 의미함.
```
레퍼런스 링크는 따로 없고 코드스테이츠에서 학습했던 또마켓 Redux 스프린트 코드를 참고했습니다.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.