Web/ReactJS
리액트에러 해결 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..
Jaybon
2021. 5. 24. 16:40
리액트에서
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 || ''}
이런식으로 널처리를 해주면 해결된다.