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

[BUG]: useLiveQuery produces 3 re-renders, only needs 2 #3568

Open
1 task done
mphill opened this issue Nov 16, 2024 · 0 comments
Open
1 task done

[BUG]: useLiveQuery produces 3 re-renders, only needs 2 #3568

mphill opened this issue Nov 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mphill
Copy link

mphill commented Nov 16, 2024

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.36.1

What version of drizzle-kit are you using?

0.28.0

Other packages

No response

Describe the Bug

When using live queries, the app re-renders 3 times due to sequential states being set.

These should be combined into a single state, or updatedAt be a ref.

const handleData = (data: any) => { setData(data); setUpdatedAt(new Date()); };

Today, when the screen renders, this is the output:

console.log(data, updatedAt);

[], undefined
[/* data is now populated*], undefined,
[/* data is now populated*], YYYY-MM-DD HH:MM:SS

The second output is where you have records but updatedAt is undefined. This should not occur. You should be able to rely on updatedAt alone to determine if your query is finished.

@mphill mphill added the bug Something isn't working label Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant