A React hook to dynamically set and get DOM/Component refs
npm install use-dynamic-refs> Made with create-react-library
 
``bash`
npm install --save use-dynamic-refs
`tsx
import React, { useEffect } from 'react';
import useDynamicRefs from 'use-dynamic-refs';
const Example = () => {
const foo = ['random_id_1', 'random_id_2'];
const [getRef, setRef] = useDynamicRefs();
useEffect(() => {
// Get ref for specific ID
const id1 = getRef('random_id_1');
console.log(id1)
}, [])
return (
<>
{/ Simple set ref. /}
{/ Set refs dynamically in Array.map() /}
{ foo.map((eachId, idx) => (
export default Example;
``
MIT © fitzmode