Skip to content

Conversation

@davideast
Copy link
Collaborator

Description

Add hooks that unwrap the QuerySnapshot returned from a reference.

Code sample

interace Person {
  id: string;
  name: string;
}

function ProfileComponent() {
  const peopleRef = firestore.collection('people');
  const personRef = peopleRef.doc('david');

  const person = useFirestoreDocData<Person>(personRef, { idField: 'id' });
  const people = useFirestoreCollectionData<Person>(ref, { idField: 'id' });
  
  return (
    <h1>{person.name}</h1>
    <ul>
       {people.map(p => <li>{p.name}</li>}
    </ul>
  );
}

@davideast davideast requested a review from jhuleatt October 11, 2019 19:28
@davideast davideast merged commit 3462ec5 into master Oct 11, 2019
@davideast davideast deleted the de-unwrap-snap branch October 11, 2019 19:57
@FirebaseExtended FirebaseExtended locked and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants