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
`제어 컴포넌트(Controlled Component)`는 폼 입력 요소의 값이 <b>React의 `상태(State)`에 의해 제어</b>되는 컴포넌트입니다.
24
+
### 개념
25
+
26
+
`제어 컴포넌트(Controlled Component)`는 폼 입력 요소의 값이 <b>React의 `상태(State)`에 의해 제어</b>되는 컴포넌트입니다. 입력값에 따른 실시간 피드백(Ex. 검색어 자동 완성), 조건부 렌더링, 유효성 검사가 필요한 경우 사용하는 것이 좋습니다.
27
+
28
+
### 동작 방식
29
+
30
+
제어 컴포넌트는 사용자 입력이 발생할 때마다 `onChange` 이벤트 핸들러를 통해 상태를 업데이트합니다. 입력값은 항상 React 상태와 동기화되며, `value` prop으로 직접 할당됩니다.
`비제어 컴포넌트(Uncontrolled Component)`는 폼 입력 요소의 값이 React 상태가 아닌 <b>DOM 자체에서 관리</b>되는 컴포넌트입니다.
71
+
### 개념
72
+
73
+
`비제어 컴포넌트(Uncontrolled Component)`는 폼 입력 요소의 값이 React 상태가 아닌 <b>DOM 내부에서 자체적으로 관리</b>되는 컴포넌트입니다. 대규모 폼에서 성능 최적화가 필요하거나, 파일 입력, 또는 서드파티 라이브러리와의 통합이 필요한 경우 사용하는 것이 좋습니다.
74
+
75
+
### 동작 방식
76
+
77
+
비제어 컴포넌트는 `ref`를 사용해 DOM 요소에 직접 접근하여 값을 가져옵니다. 초기 값은 `defaultValue`나 `defaultChecked`로 설정합니다.
- <ahref="https://ko.react.dev/learn/sharing-state-between-components#controlled-and-uncontrolled-components"target="_blank">컴포넌트 간 State 공유하기 – React</a>
138
+
- <ahref="https://goshacmd.com/controlled-vs-uncontrolled-inputs-react/"target="_blank">Controlled and uncontrolled form inputs in React don't have to be complicated</a>
0 commit comments