Home [React] 'value' prop on 'input' should not be null 에러발생
Post
Cancel

[React] 'value' prop on 'input' should not be null 에러발생


`value` prop on `input` should not be null 에러발생

팀 프로젝트를 진행하던 중 잘 동작하던 코드에 콘솔에 위와 같은 에러가 생겼다. 아무래도 백하고 통신 중 input 값에 null이나 undefined 값이 들어가서 그런 것 같다.

동작하는 데는 아무 문제가 없지만 에러 콘솔은 없을수록 좋으니...

해결방법

input에 value 부분에 null 혹은 undefined 값일 때의 대처를 작성해 준다.

1
<input value={text || " "} onChange={(value)=>textOnChange(value)}/>

마치며

혹시 잘못된 정보나 궁금하신 게 있다면 편하게 댓글 달아주세요.
지적이나 피드백은 언제나 환영입니다.

This post is licensed under CC BY 4.0 by the author.