공부한것/React
[ERROR] Typo in static class property declaration react/no-typos 해결방법
flyda
2022. 5. 13. 09:44
Prop의 타입을 설정하는 코드에서 다음과 같은 에러가 났다.
에러가 난 코드는 다음과 같다.
import PropTypes from 'prop-types'
const MyComponet = ({ name, children}) => {
return <div>나의 새롭고 멋진 컴포넌트{name} <br/>
child: {children}
</div>
}
MyComponet.defaultProps = {
name: '기본 이름'
};
MyComponet.PropTypes = {
name: PropTypes.string
};
export default MyComponet;
구글링을 해보니까 나랑 같은 문제를 겪은 사람이 있었다.
해결법은.....
MyComponet.PropTypes를 MyComponet.propTypes 로 바꾸는 것이었다.
ㅎ.... ㅋ 처음에는 해결법 보고도 뭐가 틀린거지?!!! 이랬는데 너무 어이가 없다. 대소문자... 잘 구별하자...