Styled-components 설정 : 타입스크립트 설정 후 계속 에러 나올때

Darcy Daeseok YU ·2022년 10월 7일
0

React Native 스타일드 컴포넌트 설정

어째 한방에 쉽게 가는게 없냐... ㅋ

yarn add styled-components

yarn add @types/styled-components
yarn add @types/styled-components-react-native

잘되야 햇는데

오류가 ....

Could not find a declaration file for module 'styled-components/native'.

import React from 'react';
import { Text, View } from 'react-native';
import styled from 'styled-components/native';

interface IProps {}

function TodosMainScrn({}: IProps) {
	return (
		<View style={{}}>
			<Text>TodosMainScrn</Text>
		</View>
	);
}

export default TodosMainScrn;

해결안 : https://github.com/styled-components/styled-components/issues/2370

tsconfig.json에 아래 문구 추가 : 2안 적용했음

  1. "typeRoots": ["node_modules/@types"... ],

  2. "compilerOptions": {
    // ...
    "types": [
    "@types/styled-components-react-native"
    ]
    },

profile
React, React-Native https://darcyu83.netlify.app/

0개의 댓글