How to use the reactfire.useFirestoreDocData 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>
      <span> {value} </span>
      <button> increment(1)}&gt;+</button>
    
  );
};