언어·프레임워크/React.js

[React.js] textarea에 글이 써지지 않는 문제 해결

DandyNow 2023. 3. 3. 16:52
728x90
반응형

[그림 1] textarea에 글이 써지지 않는 문제

 

회사에서 React.js 프로젝트에 투입될 예정이라 인프런 강의로 학습하던 중 [그림 1]과 같이 textarea에 글이 써지지 않는 문제가 발생했다. 콘솔창에는 아래와 같은 에러 메시지가 표시되었다. input 태그의 value 속성이 아닌 defaultValue 속성으로 변하는 값을 받아 해결할 수 있었다.

Warning: You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.

 

참고한 내용

https://bbangaro.tistory.com/28

 

[React] input value 에러 (value/defaultValue)

Warning: You provided a value prop to a form field without an onChange handler. This will render a read-only field. If the field should be mutable use defaultValue. Otherwise, set either onChange or readOnly. 기존코드는 일반 value 속성을 사용

bbangaro.tistory.com

 

추가(2023-03-06)

"value={this.state.value} onChange={this.onChangeInput}"와 같이 value, onChange를 같이 써도 됨.

728x90
반응형