React native and Gifted Chat : Error with firestore

I’m using React Native with JS.
I would like to add a chat screen using Gifted Chat.

But I’m facing an error every time the user navigate on this screen.
I put the wrong part of the code inside a try. Now, the app doesn’t crash anymore but returns this error when the user send a chat :

Cannot read properties of undefined (reading 'startAt')
at node_modules/@firebase/firestore/dist/lite/index.rn.esm2017.js:4666:27 in <global>
at node_modules/@firebase/firestore/dist/lite/index.rn.esm2017.js:4665:18 in <global>
at node_modules/@firebase/firestore/dist/lite/index.rn.esm2017.js:4562:29 in Ke#get
at Liste/ServiceDescription.js:14:29 in ServiceDescription

Here is the bugged part, it has to return the data present on firebase to put them in an array [messages]. I’m using query and orderBy to order them by date :

useLayoutEffect(() =>  {
  try {
  const collectionRef = getDocs(collection(database, 'ChatSended', uid, idUserService));
  const q = query(collectionRef, orderBy('createdAt', 'desc'));

  const unsubscribe = onSnapshot(q, snapshot => {
    console.log('snapshot');
    setMessages(
      snapshot.docs.map(doc => ({
        _id: doc.id,
        createdAt : doc.data().createdAt,
        text: doc.data().text,
        user: doc.data().user,    
      }))
    )
});
return unsubscribe;
  } catch (err) {
  console.log(err);
}
  
}
, []);

Inside node_module, the part of the code concerned is this one :

class ir extends nr {
    constructor(t, n) {
        super(), this.dt = t, this._t = n, this.type = "orderBy";
    }
    _apply(t) {
        const n = function(t, n, e) {
            if (null !== t.startAt) throw new k(A, "Invalid query. You must not call startAt() or startAfter() before calling orderBy().");
            if (null !== t.endAt) throw new k(A, "Invalid query. You must not call endAt() or endBefore() before calling orderBy().");
            const r = new sn(n, e);
            return function(t, n) {
                if (null === hn(t)) {
                    // This is the first order by. It must match any inequality.
                    const e = ln(t);
                    null !== e && gr(t, e, n.field);
                }
            }(t, r), r;
        }

In this line :

if (null !== t.startAt)

Can you please help me ?
Thanks !