title: useQuery call in onClickHandler with object of array
body: <p>I'm using react query.</p>
  <p>There is an array of documents (just describing data, no real blobs) with an option to download. They have an onClick handler which calls a function which handles the download.</p>
  <p>And in case the user clicks on the download button there is a http request getDocumentById to get the document you want to download.</p>
  <p>The Problem is, I can not call my custom query hook in that handleDownload function. But the only place I have my specific document Id is in that function.</p>
  <pre><code>const parseDocuments = () =&gt; {
      return documents.map(document =&gt; ({
        ...document,
        name: document.fileName,
        date: formatDateForUI(new Date(document.created)),
        downloadDocumentHandler: () =&gt; downloadFileClickHandler(document),
        read: document.read
      }));
    }
  
  function handleDownload(document) {
    &lt;here I need to call the getDocumentById&gt;
  }
  
  return (
    &lt;DocumentsTable documents={parseDocuments()} headers={headers} accountId={accountId} /&gt;
  )
  
  </code></pre>
  <p>How is the best way to handle this?</p>