코딩/React

TIL 22.05.02

AMD만세 2022. 5. 2. 15:53

1. React

 

1) 오늘 배운 내용

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.

-> 댓글 작성기능 추가하다가 발생.

-> 댓글란(input)에 댓글 입력하고 '작성' 버튼 누르기도 전에 콘솔창에 에러뜸.

-> input value로 undefined가 들어가서 발생한 오류.

 

2) 해결

const [comment_text, setCommentText] = React.useState();

-> const [comment_text, setCommentText] = React.useState('');

''초기값 추가해줘서 해결.

출처: https://mik-a.com/62

 

 

'코딩 > React' 카테고리의 다른 글

TIL (23.09.19) - '--isolatedModules' 에러  (0) 2023.09.19
항해99(5기) 후기  (0) 2022.04.25
프로젝트 발표영상 - 'Wewrite'  (0) 2022.04.19
WIL #12  (0) 2022.04.04
WIL #10  (0) 2022.03.20