I’m not a ReactJS expert, but an .orderBy()
is used to specify the sort order of your data and by default, a query retrieves all documents that satisfy the query in ascending order by document ID. In the first code snippet you’ve posted, it means that the results of the query
, will be printed in a descending order. Check this documentation for more information regarding order and limit data in firebase.
Additionally, useCollectionData hook has the following parameters:query
: (optional) firestore.Query
for the data you would like to load, and;
idField
: (optional) name of the field that should be populated with the firestore.QuerySnapshot.id
property.
Refer to this documentation for further instruction and guide in using Firestore with ReactJS.
0
solved Code that somehow accesses docs from firebase and displays contents that I don’t understand? REACTJS