0

State-Component

props.dictionary.words.forEach((word) => {
    return this[word] = React.createRef()
  })

Trying to do something like this with a functional-component

props.dictionary.words.forEach((word) => {
    return word = createRef()
})
skyboyer
  • 22,209
  • 7
  • 57
  • 64
  • 2
    Does this answer your question? [How to create dynamic refs in functional component- Using useRef Hook](https://stackoverflow.com/questions/57810378/how-to-create-dynamic-refs-in-functional-component-using-useref-hook) – CertainPerformance Jan 12 '21 at 21:12
  • @CertainPerformance No, I don't understand certain parts of it. I don't understand what el is or how myRefs is being populated. – jsquestionasker Jan 12 '21 at 21:28
  • The `el` in that other answer is the argument passed to the ref prop function. It gets populated when the component renders. – CertainPerformance Jan 12 '21 at 21:29
  • In addition to the reference to the other question @CertainPerformance provided, [this deep dive article in the official documentation](https://react.dev/learn/manipulating-the-dom-with-refs#how-to-manage-a-list-of-refs-using-a-ref-callback) might clarify, although their example is slightly more complex. – Shams Shimul Jul 20 '23 at 14:47

0 Answers0