Closed jellyjoji closed 1 year ago
Creator.jsx 파일에 위와 같은 오류메세지가 떠서 input 요소를 살펴보았습니다.
input form 의 경우 value 값을 설정해주면 undefined 로 값이 비어있을때 오류가 납니다.
idData 의 기본값을 ""
null 으로 설정해주고 value 값이 비어있을때 || ''
null 로 처리해주겠다는 조건과 readOnly
를 주어 값을 고정시켜 오류를 해결하였습니다.
before
const [idData, setIdData] = useState();
<FormInput readOnly value={idData.name} label="생성자" type="text" name="creator" placeholder="생성자 정보" inputClassName="w-full defaultInput" />
after
const [idData, setIdData] = useState("");
<FormInput readOnly value={idData.name || ''} label="생성자" type="text" name="creator" placeholder="생성자 정보" inputClassName="w-full defaultInput" />
내용
Warning: 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. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components
Creator.jsx 파일에 위와 같은 오류메세지가 계속 발생하여 input 요소에 문제점을 분석하였습니다.
참고 이미지 (선택)
※ 댓글에 이슈 해결 완료 후 결과 또는 해결 과정 이미지 첨부