alibaba/hooks
Ver no GitHubuseInfiniteScroll 在第一次请求还未返回时,快速切换到其他组件,会造成无限循环的请求
Open
#2.579 aberto em 25 de jun. de 2024
4 comments (4 comments)0 reactions (0 reactions)0 assignees (0 assignees)TypeScript12.849 stars (12.849 stars)2.471 forks (2.471 forks)batch import
help wanted
Description
此处会默认执行一次setTimeout,触发函数scrollMethod,当页面被销毁时,判断条件将永久成立,会一直触发loadMore
Guia do colaborador
- Pilha de tecnologia
- typescriptreact
- Domain
- frontend
- Tipo Issue
- bug
- DifficultyDificuldade de implementação estimada para um novo contribuidor, de 1 para alterações muito pequenas a 5 para trabalho de nível especializado.
- 3
- Tempo estimadoUm intervalo de tempo aproximado para um colaborador experiente investigar, implementar, testar e preparar um pull request.
- 1-3 hours
- Status da atividadeQuão disponível o issue aparece agora: novo, ativo, obsoleto, bloqueado ou aguardando entrada do mantenedor.
- fresh
- ClarityCom que clareza o issue explica a mudança esperada, os critérios de aceitação e a próxima etapa.
- mostly clear
- Prerequisites
- understanding of React hooks lifecyclebasic knowledge of useEffect cleanup
- Simpatia para novatosUma pontuação de 1 a 100 que estima o quão acessível este issue é para colaboradores iniciantes.
- 50
- Direção de pesquisa
- Investigate the useInfiniteScroll hook implementation, specifically the setTimeout call that triggers scrollMethod. The issue suggests that when the component unmounts before the timeout fires, the condition becomes permanently true causing infinite loadMore calls. Check the cleanup logic in the useEffect and ensure that the timeout is cleared on unmount. Look at the return statement of the effect to see if clearTimeout is called. The relevant file is likely `src/useInfiniteScroll/index.ts` or similar. Also review any existing comments or related PRs for proposed fixes.