일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- react-router
- ROUTER 버전6
- 2020
- classList
- 접근성
- react
- chart responsive
- classList toggle
- 커스텀훅
- 냥빨이다가온다
- 포트폴리오
- classList remove
- 간식금지다!
- chart.js
- 내배위의고양이
- 리엑트할수있는퍼블리셔라규
- 를
- 언젠간가겠지
- windowwidth
- react-router-dom
- 방심은금물
- 퍼블리싱
- classList add
- className
- resize
- 클래스 토글
- 대표님물리기없기
- 안짤렸다
Archives
- Today
- Total
틈
react+styled-components에서 overload Error가 날 때(with typescript) 본문
import React from 'react';
const Abc = () => {
return (
<Container select />
)
}
export default Abc;
import styled from 'styled-components';
export Container = styled.div<{select : boolean}>`
color: ${(props) => props.select ? 'red' : 'blue'};
`
이 호출과 일치하는 오버로드가 없습니다.(no matched overload)
typescript를 이렇게 작성했을 때, styled-component는 이상이 없었지만, react return문에서 에러가 떴습니다.
(visual studio code 한글버전이 멋대로 깔려버렸다...)
styled-component에 interface를 작성하면 해당 오류가 사라집니다.
import styled from 'styled-components';
interface ContainerProps = {
select: boolean
}
export Container = styled.div<ContainerProps>`
color: ${(props) => props.select ? 'red' : 'blue'};
`
그렇게 세 달만에 styled-component로 props를 사용할 수 있었다고 한다....
'code > React.js' 카테고리의 다른 글
[REACT] 유용한 dependencies (0) | 2022.05.07 |
---|---|
[REACT] input[type=file] 파일 이름 받아오기 (0) | 2022.05.07 |
[REACT] 실시간 화면 너비 구하기(with useEffect) (0) | 2022.03.18 |
[React] 브라우저 대응(with.javascript) (0) | 2022.03.07 |
[REACT] router (0) | 2022.01.18 |
Comments