Files
Gábor Farkas cbaf700d64 influxdb: switch the raw influxql editor from angular to react (#31860)
* influxdb: switch the raw influxql editor from angular to react

* influxdb: raw-influxql: better callback-naming

* influxdb: raw-influxql: use custom hook

* influxdb: flux: raw-editor: add unit tests
2021-03-16 10:47:33 +01:00

18 lines
465 B
TypeScript

import { useRef } from 'react';
import { uniqueId } from 'lodash';
export function useUniqueId(): string {
// we need to lazy-init this ref.
// otherwise we would call `uniqueId`
// on every render. unfortunately
// useRef does not have lazy-init builtin,
// like useState does. we do it manually.
const idRefLazy = useRef<string | null>(null);
if (idRefLazy.current == null) {
idRefLazy.current = uniqueId();
}
return idRefLazy.current;
}