mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
fix: Date.now() called causing crazy rerenders (#1057)
Fixes HDX-2185 Credit to @MikeShi42
This commit is contained in:
parent
82a31194e4
commit
7cd1d2a2ff
2 changed files with 9 additions and 4 deletions
5
.changeset/sweet-pigs-check.md
Normal file
5
.changeset/sweet-pigs-check.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@hyperdx/app": patch
|
||||
---
|
||||
|
||||
fix: endless rerenders caused by Date.now() in a component
|
||||
|
|
@ -15,6 +15,9 @@ export interface ILanguageFormatter {
|
|||
formatKeyValPair: (key: string, value: string) => string;
|
||||
}
|
||||
|
||||
// Defined outside of the component to fix rerenders
|
||||
const NOW = Date.now();
|
||||
|
||||
export function useAutoCompleteOptions(
|
||||
formatter: ILanguageFormatter,
|
||||
value: string,
|
||||
|
|
@ -94,10 +97,7 @@ export function useAutoCompleteOptions(
|
|||
where: '',
|
||||
// TODO: Pull in date for query as arg
|
||||
// just assuming 1/2 day is okay to query over right now
|
||||
dateRange: [
|
||||
new Date(Date.now() - (86400 * 1000) / 2),
|
||||
new Date(Date.now()),
|
||||
],
|
||||
dateRange: [new Date(NOW - (86400 * 1000) / 2), new Date(NOW)],
|
||||
}));
|
||||
const { data: keyVals } = useGetKeyValues({
|
||||
chartConfigs,
|
||||
|
|
|
|||
Loading…
Reference in a new issue