Advertisement
YavorGrancharov

dynamic ref

Oct 14th, 2023
849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TypeScript 0.22 KB | Software | 0 0
  1. const refs = React.useRef<any[]>([]);
  2. refs.current = Object.entries(mutationData).map(
  3.     (_, index) => refs.current[index] ?? React.createRef(),
  4. );
  5.  
  6. {arr.map((item, index) => (<Input ref={refs.current[index]} />)}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement