-
[REACT] PropTypes에서 객체 키값 여러개 정의할 때 shape()React, Next 2023. 4. 11. 21:15
PropTypes.shape로 감싼뒤 괄호() 안에 키값의 타입을 정의해준다.
PostCard.propTypes = { post: PropTypes.shape({ id: PropTypes.number, User: PropTypes.object, content: PropTypes.string, createdAt:PropTypes.object, Comments: PropTypes.arrayOf(PropTypes.object), Images: PropTypes.arrayOf(PropTypes.object) }).isRequired }
'React, Next' 카테고리의 다른 글
[REACT] Styled Component 응용하기 (0) 2023.04.11 [REACT] 퍼블리싱용 라이브러리 모음 (0) 2023.04.11 [REACT] 이미지 업로드 버튼 꾸미고 연결하기! (0) 2023.04.11 [REACT] indent(들여쓰기) Prettier, ESLint 설정 (0) 2023.04.05 로컬환경에서 실행? 개발환경에서 실행? (0) 2022.09.29