리액트에서

A component is changing a controlled input to be uncontrolled. This is likely caused by the value changing from a defined to undefined, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component.

에러가 발생할 경우 값변경이 제대로 되지 않는 경우가 있다

이 경우는 받아온 DTO나 state가 null일 경우이다

 

value={dto.name}

이렇게 들어간 코드를

value={dto.name || ''}

이런식으로  널처리를 해주면 해결된다.

'Web > ReactJS' 카테고리의 다른 글

NextJS 미들웨어  (0) 2022.04.20
NextJS Api 키 등 중요 변수 숨기기  (0) 2022.04.19
intellij 인텔리제이 eslint typescript prettier  (0) 2021.02.19
react js / next js quill 적용  (0) 2021.02.17
next js 시작하기  (0) 2021.02.15

+ Recent posts