()
| 16 | import { initializeFirestore, doc, collection, enableIndexedDbPersistence, increment, updateDoc, orderBy, query, addDoc, deleteDoc, DocumentData } from 'firebase/firestore'; |
| 17 | |
| 18 | const Counter = () => { |
| 19 | const firestore = useFirestore(); |
| 20 | |
| 21 | const ref = doc(firestore, 'count', 'counter'); |
| 22 | |
| 23 | const incrementCounter = (amountToIncrement) => { |
| 24 | updateDoc(ref, { |
| 25 | value: increment(amountToIncrement), |
| 26 | }); |
| 27 | }; |
| 28 | |
| 29 | const { data: count } = useFirestoreDocData(ref); |
| 30 | |
| 31 | return ( |
| 32 | <> |
| 33 | <button onClick={() => incrementCounter(-1)}>-</button> |
| 34 | <span> {(count as any).value} </span> |
| 35 | <button onClick={() => incrementCounter(1)}>+</button> |
| 36 | </> |
| 37 | ); |
| 38 | }; |
| 39 | |
| 40 | const StaticValue = () => { |
| 41 | const firestore = useFirestore(); |
nothing calls this directly
no test coverage detected