How to use custom query ? #752
-
Hi, I want to get the total number of files in that particular location.
I should get totalNumber of files = 4
I know the query is listed incorrectly. Could you help me write a proper graphql query and provide relevant documentation regarding it because I don't seem to find it properly listed in contember docs. I only see things regarding Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I have identified that the issue is with metadata.length, however I am not sure about how to fix it, also what should be passed inside the dependency array of the useEffect, if I pass the totalFileCount, I get random values.. |
Beta Was this translation helpful? Give feedback.
-
Hi,
The problem is as I delete the file from DataGrid, the state of fileCount is not being updated and thus I have to manually reload the page to see the effect |
Beta Was this translation helpful? Give feedback.
Hi, the issue occurs because your
fileCount
isn't automatically updated when a file is deleted. You're correctly fetchingfileCount
in theuseEffect
, but since deletion doesn't trigger the dependencies you specified, the count doesn't update automatically.A simple and effective solution is to explicitly call your
listFiles
function again after the delete operation succeeds, like this:This way, whenever you successfully delete a file, your
fileCount
state will immediately reflect the changes without requiring a manual reload.Additionally, to clarify your dependencies, you can safel…