Files
redash/client/app/lib/hooks/useLazyRef.ts
Rafael Wendel fb90b501cb Improve icon a11y (#5424)
* Added screen reader CSS

* Added description to external links

* Added spinner icon accessibility

* Added accessibility to exclamation and big message

* Added question and exclamation accessibility

* Hide decorative icons

* Standardized link design

* Added a11y to refresh icons

* Added aria-label to anchors and buttons

* Added a11y to conditional icons

* Added applicable labels to Ant Icons

* Changed escape to interpolation

* Replaced external links with opens in new tab

* Improved Tooltip hosts

* Added aria live to temporary elements

* Removed mistakenly added redundant helper

* Undoes unnecessarily added interpolation

* Replaced empty label with hidden

* Improved full icon label

* Improved display of live regions

* Added note

* remove unused class

* Created unique id

* Remove TODOs

* Proper action label

* Improved feedback for autocomplete toggle

* feature: add id hook

* refactor: use id hook

* standardize white space
2021-03-22 19:49:36 -03:00

12 lines
256 B
TypeScript

import { useRef } from "react";
export function useLazyRef<T>(getInitialValue: () => T) {
const lazyRef = useRef<T>(null) as React.MutableRefObject<T>;
if (lazyRef.current === null) {
lazyRef.current = getInitialValue();
}
return lazyRef;
}