You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a known and explicit issue, and the author is no longer maintained.
It has also been mentioned in other issues how to fix it. ( #391#380 )
If you don't intend to change other components or fork to fix bug, you can refer to my solution for fixing it.
import{useDebounceFn,useMount}from"ahooks";exportfunctionuseFixScroll(hasMore: boolean,fetchMore: ()=>void){// debounce is necessaryconstfixFetch=useDebounceFn(()=>{constfirstLoaderItem=document.querySelector(".loader-item");constscrollContainer=document.querySelector(".scroll-container");if(!firstLoaderItem||!scrollContainer){return;}if(// only when user do not scroll content// The loading will continue only when the loader element appears on the scroll-container.scrollContainer.scrollTop===0&&firstLoaderItem.getBoundingClientRect().top<scrollContainer.getBoundingClientRect().bottom){// console.log("fixed");fetchMore();}},{wait: 500,},);// useMount equals useEffect(()=>{doSomething();},[]); useMount(()=>{constobserver=newMutationObserver((mutationsList)=>{for(letmutationofmutationsList){if(mutation.type==="childList"){// console.log("Child nodes have been added or removed.");fixFetch.run();}}});if(!hasMore){return;}// scroll-items-container is the container for the items.consttargetNode=document.getElementById("scroll-items-container");if(!targetNode){return;}constconfig={childList: true,subtree: false};// console.log("start observe");observer.observe(targetNode,config);return()=>{observer.disconnect();};});}
The text was updated successfully, but these errors were encountered:
othorizon
changed the title
【IMPORT】HOW TO FIX:Don't load new items when content height <= screen height
【IMPORT FOR EVERYONE】HOW TO FIX:Don't load new items when content height <= screen height
Mar 11, 2024
its any one found the solution, i have same problem and my project is near to complete, its dificult to change library
@hamzashakir99 What I mentioned above, that is my solution.just copy it and call this function
othorizon
changed the title
【IMPORT FOR EVERYONE】HOW TO FIX:Don't load new items when content height <= screen height
【IMPORTANT FOR EVERYONE】HOW TO FIX:Don't load new items when content height <= screen height
Nov 10, 2024
This is a known and explicit issue, and the author is no longer maintained.
It has also been mentioned in other issues how to fix it. ( #391 #380 )
If you don't intend to change other components or fork to fix bug, you can refer to my solution for fixing it.
The text was updated successfully, but these errors were encountered: