drizzle-team / drizzle-team/drizzle-orm

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

Open
#3,568 0 comments 0 reactions 0 assignees View on GitHub
bug driver/expo-sqlite
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [X] 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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.