我想在我的react项目中使用react显示包。是我安装的。但是react找不到模块
Could not find a declaration file for module 'react-reveal/Fade'.
但是,在package.json文件和节点模块中显示的是react显示。
"dependencies": {
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"bootstrap": "^4.6.0",
"jquery": "^3.6.0",
"react": "^17.0.2",
"react-bootstrap": "^1.6.1",
"react-dom": "^17.0.2",
"react-parallax": "^3.3.0",
"react-reveal": "^1.2.2",
"react-router-bootstrap": "^0.25.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-scroll": "^1.8.2",
"react-water-wave": "^1.0.5",
"web-vitals": "^1.1.2"
},我试着安装npm i --save-dev @types/react-reveal。
然后这个错误就来了
'@types/react-reveal@latest' is not in the npm registry.
我怎么才能解决这个问题?
注:我没有使用打字稿
发布于 2021-10-18 03:05:43
使用require导入包
import "./Product.scss"
//use require to import the module
const Fade = require("react-reveal/Fade")
export interface IProduct {
price: number
title: string
img: string
}
const Product: React.FC<IProduct> = ({ price, title, img }) => {
return (
<Fade bottom cascade>
<li className="product-wrapper">
<div className="product-container">
<img src={`${img}`} alt="" />
<div className="main-details">
<div className="title">{title}</div>
<div className="details">
<div className="price">Price: $ {price}</div>
<div className="button-wrapper">
<button className="button btn-primary">
Add to cart
</button>
</div>
</div>
</div>
</div>
</li>
</Fade>
)
}
export default Product尝试了这个实现,它成功了。
发布于 2021-10-18 03:13:19
运行以下命令without typescript
nom install react-reveal
npm install react-reveal/Fade --save
或
import { Fade } from 'react-reveal';https://stackoverflow.com/questions/68037185
复制相似问题