I am getting the following error when I am adding the orderBy('crearedAt') on the Firestore collection.
[Error: [firestore/failed-precondition] The query requires an index.
my collection is
export const CommentsCollection = firestore().collection('comments');
When i am adding the orderBy('createdAt') like
let commentsQuery = CommentsCollection.orderBy('createdAt').where('postId', '==', data.postId);
I have already created the index on the Firebase console.
When you call .orderBy('createdAt')
the required index is ascending but in your screenshot, I see that it is set descending. So to solve this you have to create another index where you need to set createdAt
ascending.