How to use the reactfire.useFirestore function in reactfire

To help you get started, we’ve selected a few reactfire examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FirebaseExtended / reactfire / sample / src / Firestore.js View on Github external
const Counter = props => {
  const firestore = useFirestore();

  const serverIncrement = firestore.FieldValue.increment;

  const ref = firestore().doc('count/counter');

  const increment = amountToIncrement => {
    ref.update({
      value: serverIncrement(amountToIncrement)
    });
  };

  const { value } = useFirestoreDocData(ref);

  return (
    <>
      <button> increment(-1)}&gt;-</button>
github FirebaseExtended / reactfire / sample / src / Firestore.js View on Github external
const FavoriteAnimals = props => {
  const firestore = useFirestore();
  const baseRef = firestore().collection('animals');
  const [isAscending, setIsAscending] = useState(true);
  const query = baseRef.orderBy('commonName', isAscending ? 'asc' : 'desc');
  const [startTransition, isPending] = useTransition({
    timeoutMs: 1000
  });

  const toggleSort = () => {
    startTransition(() => {
      setIsAscending(!isAscending);
    });
  };

  const addNewAnimal = commonName =>
    baseRef.add({
      commonName