Open babakness opened 6 years ago
To the "why not do this" part of the question: querySelector
/ querySelectorAll
are not live queries, so what you'd do in componentDidMount
is take a snapshot of whichever .foo
DOM elements exist at that particular point in time — they can, and probably will, change throughout the component's life.
Please document how to use forwardRef (the preferred way) to retrieve a list or array of items. For example,
Perhaps the key question here is, why not do this?
Suppose there are 50,000
className='foo'
elements that are returned by an embedded component. Is this code not portable? Is this code slower than having 50,000ref
created?Please document this.