How do I create a Firestore query for documents created after a timestamp in the new modular sdk?

I am rather new to Firestore, not to mention the new modular sdk, and I was wondering if anyone knows why this query returns a document with a createdAt timestamp that was before the timestamp that I provided? I only want documents that were created after the timestamp I provide.

const timeRef = useRef(Date.now());

const notificationQuery = query(
   collection(clientFirestore, `users/${uid}/notification_history`),
   orderBy("createdAt"),
   where("createdAt", ">=", timeRef.current),
   limit(1)
 );

I also tried this:

const notificationQuery = query(
   collection(clientFirestore, `users/${uid}/notification_history`),
   orderBy("createdAt"),
   startAfter(timeRef.current),
   limit(1)
);

Am I misusing the date or is the query wrong?

Answer

This seems illogical: useRef(Date.now()). Date.now() gives you a number, not a path that you can pass to useRef.

Are you looking for Timestamp.now()?

where("createdAt", ">=", Timestamp.now()),