forked from Gitlink/forgeplus-react
commit提交记录分页问题‘
This commit is contained in:
parent
b863d8bfe6
commit
6b9f413532
|
@ -58,7 +58,6 @@ export default (props) => {
|
|||
const { sha , projectsId, owner } = match.params;
|
||||
|
||||
const [ dropLoading, setDropLoading] = useState(false); //加载loading
|
||||
const [hasMore, setHasMore] = useState(true); //是否还有更多数据需要加载
|
||||
const limit = 200;
|
||||
const fRef = useRef();
|
||||
|
||||
|
@ -107,8 +106,9 @@ export default (props) => {
|
|||
|
||||
async function InitDiffData (){
|
||||
let f = fRef.current ? fRef.current.files : [];
|
||||
let p = (fRef.current && fRef.current.page) || 1;
|
||||
if (!hasMore || dropLoading || !isSpin) {
|
||||
let p = fRef.current ? fRef.current.page : 1;
|
||||
let hm = fRef.current ? fRef.current.hasMore : true;
|
||||
if (!hm || dropLoading || !isSpin) {
|
||||
return;
|
||||
}
|
||||
setDropLoading(true);
|
||||
|
@ -119,8 +119,7 @@ export default (props) => {
|
|||
if(res?.status === 200){
|
||||
let arr = p === 1 ? res.data.files : [...f,...res.data.files];
|
||||
setData(res.data);
|
||||
fRef.current = {files:arr,page:p+1};
|
||||
setHasMore(arr.length === limit);
|
||||
fRef.current = {files:arr,page:p+1,hasMore:arr.length === limit};
|
||||
setDropLoading(false);
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue