drizzle-team / drizzle-team/drizzle-orm
[BUG]: useLiveQuery produces 3 re-renders, only needs 2
- 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
Assessment
This issue has not been assessed yet.