Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ページネーションのバグ修正 #620

Merged
merged 1 commit into from
Aug 26, 2024
Merged

ページネーションのバグ修正 #620

merged 1 commit into from
Aug 26, 2024

Conversation

tbrand
Copy link
Contributor

@tbrand tbrand commented Aug 26, 2024

No description provided.

const isLoading = useMemo(() => {
if (!data) return false;
return data!.length < size || data![size - 1] === undefined;
}, [data, size]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useSWRInfinite の isLoading は使わず、size が増えたのに data がまだ入っていない状態を loading と定義しました

@@ -5,7 +5,7 @@ import { ListChatsResponse, Chat } from 'generative-ai-use-cases-jp';

const useChatList = () => {
const { listChats, deleteChat: deleteChatApi, updateTitle } = useChatApi();
const { data, size, setSize, isLoading, mutate } = listChats();
const { data, size, setSize, mutate } = listChats();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useSWRInfinite の isLoading が、いわゆる何かページ目かを読み込んでいる時に true になるという動作ではないようでバグになっていました。そこで useSWRInfinite の isLoading は使わないようにしました。

Copy link
Contributor

@wadabee wadabee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@wadabee wadabee merged commit 59d8a2b into main Aug 26, 2024
3 checks passed
@wadabee wadabee deleted the fix-pagination branch August 26, 2024 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants