💡문제
input value에 undefined로 들어갔을 때 생기는 문제가 다음과 같이 콘솔에 찍혔다.
Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components
💪🏻해결
input 값의 value를
<S.Title
value={title}
onChange={(e)=>onChangeTitle(e)}
/>
이상태에서
<S.Title
value={title || ''}
onChange={(e)=>onChangeTitle(e)}
/>
이렇게 undefined일 때는 빈 string 값이 들어갈 수 있도록 변경해주었다.
'프로젝트 > 사이드프로젝트1' 카테고리의 다른 글
Next.js + styled-component 에서 table 요소에 hover 넣기 (0) | 2023.02.02 |
---|---|
이 JSX 태그의 'children' 속성에는 'ReactNode' 형식의 자식 하나가 필요하지만, 여러 자식이 제공되었습니다. (0) | 2023.01.31 |
Next.js 에서 alert창을 띄우고 확인 버튼을 눌렀을 때 navigate 하는 법 (0) | 2023.01.30 |