에러일지/React.js
[React] Property '*' does not exist on type 'ThemeProps<any>'.
레오나르도 다빈츠
2023. 2. 8. 19:50
에러
Property 'size' does not exist on type 'ThemeProps<any>'.
Property 'size' does not exist on type 'ThemeProps<any>'.
원인
const sizeStyles = css`
${({ size }) => css`
padding: ${sizes[size].padding}
font-size: ${sizes[size].fontSize}
`}
`
타입을 모조리 지정해주었다.
type Size = {
[key: string]: {
padding: string
fontSize: string
}
}
const sizes: Size = {
large: {
padding: '10px 15px',
fontSize: '15px',
},
medium: {
padding: '15px 20px',
fontSize: '17px',
},
small: {
padding: '20px 25px',
fontSize: '20px',
},
}
개인적으로 공부한 내용을 정리하는 블로그로
잘못된 개념을 게시하지않도록 주의하고 있으나 오류가 있을 수 있습니다.