react-window用InfiniteLoader包裹后如何获取ref?-灵析社区

我想对你说

import { useRef } from 'react'; import { VariableSizeList as List, areEqual } from 'react-window'; import InfiniteLoader from 'react-window-infinite-loader'; const Demo = () => { const listRef = useRef(); const click = () => { if (listRef.current) { listRef.current.scrollToItem(0); } }; return ( click ); }; const ListWrap = ({ hasNextPage, isNextPageLoading, loadNextPage, listRef }) => { return ( {({ onItemsRendered, ref }) => { return ( { ref(instance); listRef.current = instance; }} > {Cell} ); }} ); };

阅读量:1

点赞量:0

问AI