简体   繁体   中英

react country flag in react with typescript project

Hey I am recently working with react and typescript together and I wanted to have some country logos, I installed this package which seems to be the most popular one for reactjs, the package called react country flag, and I cannot use it maybe with ts? is that the case? my error is the one in the image below.

在此处输入图像描述

The package does not come with typescript types, do this in the terminal. This will try to download the types for that package if they exist

npm i --save-dev @types/react-country-flag

If it still doesn't exist, add

//@ts-ignore above the import line, like this:

//@ts-ignore
import ReactCountryFlag from "react-country-flag"

That will ignore the error you are having

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM