Skip to content

Remove NO_ID_FIELD key from data hooks #295

Closed

Description

@jhuleatt

Remove NO_ID_FIELD key from useFirestoreDocData,useFirestoreCollectionData, useDatabaseListData, useDatabaseObjectData.

This key is inserted when no idField option is passed to these functions. However, it ends up being pretty confusing. Instead, if idField is not provided, we can just omit the document id.

Activity

  1. added this to the 3.0.0 milestone on Dec 10, 2020
  2. SabrinaDanielle commented on Dec 13, 2020

    @SabrinaDanielle

    Hello, I think my issue may be slightly unrealtated; however, when following the example in the quickstart, instead of getting a boolean value I get "{NO_ID_FIELD: undefined}".

  3. SabrinaDanielle commented on Dec 13, 2020

    @SabrinaDanielle
    import React from "react";
    import { useFirestoreDocData, useFirestore, SuspenseWithPerf } from "reactfire";
    
    const Products = () => {
      const burritoRef = useFirestore().collection("tryreactfire").doc("burrito");
      // subscribe to a document for realtime updates. just one line!
      const burrito = useFirestoreDocData(burritoRef);
    
      if (burrito.status === "loading") {
        return <p>Fetching burrito flavor...</p>;
      }
    
      return (
        <SuspenseWithPerf
          fallback={<p>"Loading store stuff..."</p>}
          traceId={"Loading Store"}
        >
          <div>
            Products
            <p>
              The burrito is
              {burrito.yummy ? "good" : "bad"}!
            </p>
          </div>
        </SuspenseWithPerf>
      );
    };
    
    export default Products;
  4. maxprilutskiy commented on Dec 30, 2020

    @maxprilutskiy
    Contributor

    @jhuleatt Jeff, in that case, how do we get the id of a created document, when it's generated by Firebase?
    I believe it makes sense to still have something like _uid attached to docs.

  5. jhuleatt commented on Jan 6, 2021

    @jhuleatt
    CollaboratorAuthor

    @SabrinaDanielle it looks like the quickstart code is outdated, apologies for that. I filed #321 to fix the quickstart.

  6. devth commented on Mar 8, 2021

    @devth

    Agree, why not default it to _id or something? Alternatively, let users set a global default so we don't have to keep passing { idField: "id" } on all useFirestoreCollectionData calls.

  7. cd-a commented on Mar 21, 2021

    @cd-a

    I agree with this. I'm even fine with keeping the current behaviour, as long as we have a way of omitting the id field completely.

    We don't always need it. If I target a specific document only, I already know the Id, otherwise I can't target it. So having that field in there makes me have to filter it out every time i want to use the data.

  8. locked and limited conversation to collaborators on Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions