This library is used for querying focusable elements, but it is query Real DOM.
https://github.com/jkup/focusable
And I would like to do the same with that by React Ref API, but I don't know how to do.
Example of library's code
const focusableElements = document.querySelectorAll('a[href], area[href], input:not([disabled]):not([type="hidden"]), [tabindex], ...')
Thing what I want
function MyComponent() {
const elementRef = useRef<HTMLDivElement>(null)
// How to access every focusable (input, button, and div which it has `tabindex` attr)?
const focusableElements = elementRef?.current.xxx.yyy.zzz ???
return (
<div ref={elementRef}>
<input />
<button />
<section>
<div tabindex={0} />
</section>
</div>
)
}