useQueries - adding a queryKey or any way to mark the result?
Hi ALL!
Have a question if there is a way to mark the queries somehow?
I have written a useQueries hook that fetches images from our API ( behind a Auth header, that's why I'm fetching the data blob ). The data for the items ( ids, names, diff. info ) is passed down from a parent component ( MUI Stepper Dialog uses the data ) and I display it in a list with the item data ( as a 'preview' that gets sent to our API to be printed ).
When I call the hook the useQueries returns the array of all the queries triggered with the standard query object as a response.
Now the question is if there is a way to mark those response objects so that I can the correct query with the correct image?
I get the Item data in an array and I pass that array to my useQueries to fetch the images - how I then check if the image has been fetched is with the iteration index of the array - which gives me the result I'm looking for...
BUT: is this safe?
Any help would be much appreciated 😄
4 Replies
genetic-orange•4y ago
can you show some code?
optimistic-goldOP•4y ago
Hi - sorry was away 😄
optimistic-goldOP•4y ago
optimistic-goldOP•4y ago
selectedCodes is the one with the data for the item data rendering - and then the queries are the ones I have to bind to the mapping of the selected codes. array index based seems legit since I get the selectedCodes as an array which I then pass as an argument to the queries hook