how to refetch with a passed in variable, state is behind
I'm strugging with the best way to handle this. I have a button in my web app that generates an Excel spreadsheet in the backend and sends it to the browser as a download. When the button is clicked, it passes an id to a function so it knows which list to go create a spreadsheet of. I am saving that id into state, but that is not working because of how state works and it is always behind by a click.
The function that runs on the click is this one:
And the useQuery with the refetch:
The function that runs on the click is this one:
And the useQuery with the refetch: