codestates / codestates/Memory-It

[Error Handling] State Lifting으로 데이터를 전달하려고했는데 Warning 메세지 발생

Open
#205 1 comment 0 reactions 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

### 어떤 에러인가요?
+ State Lifting으로 형제 컴포넌트로 데이터를 전달하려고 했는데 콘솔에 Warning 메세지가 떴습니다.
### 에러 메시지
```
Cannot update a component (`App`) while rendering a different component (`DiaryType`).
To locate the bad setState() call inside `DiaryType`,
follow the stack trace as described in https://reactjs.org/link/setstate-in-render
```

### 에러 핸들링 방법
+ 이 문제는 형제 컴포넌트로 데이터를 보내기 위하여 state lifting을 사용하면 나타난다.
+ state lifting을 하는 과정에서 부모 컴포넌트에 데이터를 보존하려고 useState Hook을 사용하게 되는데, 거기서 정상적인 방법이 아니라는 메세지가 뜨게 된다.
+ 이 문제의 핵심은 리액트 데이터 흐름을 역행하는 것이다.
+ 리액트 데이터 흐름을 역행하지 않고 문제를 해결하기 위해서는 데이터를 Redux로 관해 주어야 한다.
+ 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.