【发布时间】:2021-01-15 03:24:24
【问题描述】:
我安装了 react-scroll-to-bottom 并通过依赖项显示它,但我不断收到此错误:
找不到模块“react-scroll-to-bottom”的声明文件。 'c:/Users/J/Desktop/webapps/ChatApp/client/node_modules/react-scroll-to-bottom/lib/index.js' 隐含了一个 'any' 类型。
尝试npm install @types/react-scroll-to-bottom(如果存在)或添加包含declare module 'react-scroll-to-bottom'; 的新声明(.d.ts)文件
这是我的 package.json 文件。
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"query-string": "^6.13.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-emoji": "^0.5.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"react-scroll-to-bottom": "^4.0.0",
"socket.io-client": "^2.3.0"
},
这是我的js代码:
import React from 'react';
import ScrollToBottom from 'react-scroll-to-bottom';
import Message from './Message/Message'
import './Messages.css';
const Messages = ({ messages, name }) => (
<ScrollToBottom classname="messages">
{messages.map((message, i) => <div key={i}><Message message={message} name={name} /></div>)}
</ScrollToBottom>
);
export default Messages;
【问题讨论】:
-
签入你的 npm 模块,
dependencies和devdependencies只是一个参考。 -
对不起,我很困惑,这是什么意思?
标签: javascript reactjs react-native npm