title: How to get a reference to a DOM element that depends on an input parameter?
body: <p>Say I have the standard TODO app, and want a ref to the last item in the list. I might have something like:</p>
  <pre><code>const TODO = ({items}) =&gt; {
    const lastItemRef = Reeact.useRef()
    return {
      &lt;&gt;
        {items.map(item =&gt; &lt;Item ref={item == items.last() ? lastItemRef : undefined} /&gt;)}
      &lt;&gt;
    }
  }
  </code></pre>
  <p>But this doesn't seem to work - after <code>lastItemRef</code> is initialized, it is never subsequently updated as items are added to <code>items</code>. Is there a clean way of doing this without using a selector?</p>