`import React, { useEffect, useState } from 'react'; import style from './index.module.scss'; import cx from 'classnames'; import { HistoryItem } from '../HistoryItem'; import InfiniteScroll from 'react-infinite-scroll-component';
interface Props { data: any; }
export const HistoryList = ({ data, fetchMoreData }: Props) => { return (
<InfiniteScroll
scrollableTarget="container-body"
dataLength={data.length}
next={fetchMoreData}
hasMore
loader={
);
};
`
Loading...
} > {data.map(({ time, content, type }) => { return ; })}今天用了react-infinite-scroll-component下拉滚动的组件,坑了我两个小时,组件的用法挺简单的,但由于我刚接手项目,对项目不熟悉。这个组件下拉就是不生效。后来大佬和我说要指定下滚动的父元素。于是我加了 scrollableTarget="container-body"这个属性,就可以正常了,糊涂啊!!!!!!
**如何避免?
-
需要浏览一遍组件的api
-
多想案例上每个属性的含义是什么?
-
由滚动想到滚动父元素 **