문제의 코드, children에 계속 밑줄이 그어짐
const TodosContextProvider: React.FC<Props> = (props) => {
return (
<TodosContext.Provider value={contextValue}>
{props.children}
</TodosContext.Provider>
)
}
해결
type Props = {
children?: React.ReactNode;
};
children 정의. react 18 에선 children지원하지 않는다고 함.
리액트 18의 타입스크립트 타입 변경점
React(리액트) 18이 얼마 전에 출시했습니다. 개발하시는 프로젝트에 이미 업데이트 했거나 조만간 업데이트 하실 계획일텐데요. 리액트와 Typescript(타입스크립트)를 같이 사용했던 프로젝트라면
blog.shiren.dev
'frontend > React' 카테고리의 다른 글
[react-i18next] 한영 번역 라이브러리 (0) | 2023.10.20 |
---|---|
Redux-toolkit을 사용해야하는 이유 (Feat.미들웨어) (0) | 2022.12.17 |